From 7934597aecc8e29054fb17710fc278ad7ad88b12 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 6 Apr 2024 13:01:21 +0200 Subject: [PATCH] FEAT: implement `--repo-organization` flag (#342) --- src/compwa_policy/.github/release-drafter.yml | 2 +- src/compwa_policy/check_dev_files/__init__.py | 7 +++++++ .../check_dev_files/release_drafter.py | 20 +++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/compwa_policy/.github/release-drafter.yml b/src/compwa_policy/.github/release-drafter.yml index d7ebebc4..480de929 100644 --- a/src/compwa_policy/.github/release-drafter.yml +++ b/src/compwa_policy/.github/release-drafter.yml @@ -36,4 +36,4 @@ template: | $CHANGES - _The full changelog as commits can be found [here](https://github.com/ComPWA/<>/compare/$PREVIOUS_TAG...$NEXT_PATCH_VERSION)._ + _The full changelog as commits can be found [here](https://github.com/<>/<>/compare/$PREVIOUS_TAG...$NEXT_PATCH_VERSION)._ diff --git a/src/compwa_policy/check_dev_files/__init__.py b/src/compwa_policy/check_dev_files/__init__.py index 4c01264f..f0ec3b0a 100644 --- a/src/compwa_policy/check_dev_files/__init__.py +++ b/src/compwa_policy/check_dev_files/__init__.py @@ -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) @@ -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="", diff --git a/src/compwa_policy/check_dev_files/release_drafter.py b/src/compwa_policy/check_dev_files/release_drafter.py index 4bbbd373..35aebf38 100644 --- a/src/compwa_policy/check_dev_files/release_drafter.py +++ b/src/compwa_policy/check_dev_files/release_drafter.py @@ -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) @@ -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) @@ -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) + config[key] = ( + "\n".join(lines) + .replace("<>", organization) + .replace("<>", repo_name) + ) return config