Skip to content

Commit

Permalink
FEAT: implement --repo-organization flag
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Apr 6, 2024
1 parent 2c71333 commit facc444
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compwa_policy/.github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ template: |
$CHANGES
_The full changelog as commits can be found [here](https://github.com/ComPWA/<<REPO_NAME>>/compare/$PREVIOUS_TAG...$NEXT_PATCH_VERSION)._
_The full changelog as commits can be found [here](https://github.com/<<ORGANIZATION>>/<<REPO_NAME>>/compare/$PREVIOUS_TAG...$NEXT_PATCH_VERSION)._
7 changes: 7 additions & 0 deletions src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def main(argv: Sequence[str] | None = None) -> int:
args.repo_name,
args.repo_title,
github_pages=args.github_pages,
organization=args.repo_organization,
)
do(mypy.main)
do(pyright.main, precommit_config)
Expand Down Expand Up @@ -276,6 +277,12 @@ def _create_argparse() -> ArgumentParser:
required=True,
type=str,
)
parser.add_argument(
"--repo-organization",
default="ComPWA",
help="Name of the organization under which the repository lives.",
type=str,
)
parser.add_argument(
"--repo-title",
default="",
Expand Down
20 changes: 14 additions & 6 deletions src/compwa_policy/check_dev_files/release_drafter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml


def main(repo_name: str, repo_title: str, github_pages: bool) -> None:
def main(
repo_name: str, repo_title: str, github_pages: bool, organization: str
) -> None:
update_file(CONFIG_PATH.release_drafter_workflow)
_update_draft(repo_name, repo_title, github_pages)
_update_draft(repo_name, repo_title, github_pages, organization)


def _update_draft(repo_name: str, repo_title: str, github_pages: bool) -> None:
def _update_draft(
repo_name: str, repo_title: str, github_pages: bool, organization: str
) -> None:
yaml = create_prettier_round_trip_yaml()
expected = _get_expected_config(repo_name, repo_title, github_pages)
expected = _get_expected_config(repo_name, repo_title, github_pages, organization)
output_path = CONFIG_PATH.release_drafter_config
if not os.path.exists(output_path):
yaml.dump(expected, output_path)
Expand All @@ -31,7 +35,7 @@ def _update_draft(repo_name: str, repo_title: str, github_pages: bool) -> None:


def _get_expected_config(
repo_name: str, repo_title: str, github_pages: bool
repo_name: str, repo_title: str, github_pages: bool, organization: str
) -> dict[str, Any]:
yaml = create_prettier_round_trip_yaml()
config = yaml.load(COMPWA_POLICY_DIR / CONFIG_PATH.release_drafter_config)
Expand All @@ -41,7 +45,11 @@ def _get_expected_config(
lines = config[key].split("\n")
if not os.path.exists(CONFIG_PATH.readthedocs) or github_pages:
lines = lines[2:]
config[key] = "\n".join(lines).replace("<<REPO_NAME>>", repo_name)
config[key] = (
"\n".join(lines)
.replace("<<ORGANIZATION>>", organization)
.replace("<<REPO_NAME>>", repo_name)
)
return config


Expand Down

0 comments on commit facc444

Please sign in to comment.