From e2ad8d28fd5a42e895d33a2fc740908172449f17 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 15 Jun 2026 10:19:35 +0200 Subject: [PATCH 1/2] Dust off bootstrap templates Amongst other oversights, this properly propagates the git repository choice from the bootstrap template to the others. Fixes #1428 Fixes #1434 --- CHANGES/1428.misc | 1 + CHANGES/1434.misc | 1 + .../pyproject.toml | 4 ++-- .../pyproject.toml | 1 + cookiecutter/ci/hooks/post_gen_project.py | 9 ++++----- .../.ci/scripts/validate_commit_message.py | 15 +++++++++++---- .../pyproject.toml.update | 2 ++ 7 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 CHANGES/1428.misc create mode 100644 CHANGES/1434.misc diff --git a/CHANGES/1428.misc b/CHANGES/1428.misc new file mode 100644 index 000000000..e8108a3bf --- /dev/null +++ b/CHANGES/1428.misc @@ -0,0 +1 @@ +Dust off bootstrap template. diff --git a/CHANGES/1434.misc b/CHANGES/1434.misc new file mode 100644 index 000000000..e8108a3bf --- /dev/null +++ b/CHANGES/1434.misc @@ -0,0 +1 @@ +Dust off bootstrap template. diff --git a/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml b/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml index 03f71efce..12c105b4d 100644 --- a/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml +++ b/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml @@ -26,5 +26,5 @@ dependencies = [ ] [project.urls] -repository = "https://github.com/pulp/{{ cookiecutter.__project_name }}" -changelog = "https://github.com/pulp/{{ cookiecutter.__project_name }}/blob/main/CHANGES.md" +repository = "{{ cookiecutter.repository }}" +changelog = "{{ cookiecutter.repository }}/blob/main/CHANGES.md" diff --git a/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pyproject.toml b/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pyproject.toml index 8b0955b89..9cf84b9a5 100644 --- a/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pyproject.toml +++ b/cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pyproject.toml @@ -39,6 +39,7 @@ changelog = "{{ cookiecutter.repository }}/blob/main/CHANGES.md" app_label = {{ cookiecutter.app_label | toml_value }} glue = {{ cookiecutter.glue | toml_value }} docs = {{ cookiecutter.docs | toml_value }} +repository = {{ cookiecutter.repository | toml_value }} src_layout = true translations = {{ cookiecutter.translations | toml_value }} diff --git a/cookiecutter/ci/hooks/post_gen_project.py b/cookiecutter/ci/hooks/post_gen_project.py index 75f845b09..320d30974 100644 --- a/cookiecutter/ci/hooks/post_gen_project.py +++ b/cookiecutter/ci/hooks/post_gen_project.py @@ -6,7 +6,9 @@ for base_path in [ ".", + {%- if cookiecutter.glue %} "pulp-glue{{ cookiecutter.__app_label_suffix }}", + {%- endif %} ]: # Merge pyproject.toml.update into pyproject.toml with open(os.path.join(base_path, "pyproject.toml"), "r") as fp: @@ -17,13 +19,10 @@ # TODO How deep is your merge? # Is merging on the tool level appropriate? - pyproject_toml["tool"].update(pyproject_toml_update["tool"]) + pyproject_toml.setdefault("tool", {}).update(pyproject_toml_update["tool"]) if "dependency-groups" in pyproject_toml_update: - if "dependency-groups" not in pyproject_toml: - pyproject_toml["dependency-groups"]=pyproject_toml_update["dependency-groups"] - else: - pyproject_toml["dependency-groups"].update(pyproject_toml_update["dependency-groups"]) + pyproject_toml.setdefault("dependency-groups", {}).update(pyproject_toml_update["dependency-groups"]) # Remove legacy tools. for tool in ["flake8", "black", "isort"]: diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/validate_commit_message.py b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/validate_commit_message.py index dc9db4faa..df1a296cd 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/validate_commit_message.py +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/validate_commit_message.py @@ -1,7 +1,9 @@ # /// script # requires-python = ">=3.11" # dependencies = [ +{%- if cookiecutter.repository.startswith("https://github.com/") %} # "pygithub>=2.8.1,<3.0.0", +{%- endif %} # ] # /// @@ -12,7 +14,6 @@ from pathlib import Path import tomllib -from github import Github with Path("pyproject.toml").open("rb") as fp: PYPROJECT_TOML = tomllib.load(fp) @@ -36,16 +37,22 @@ if any(re.match(pattern, message) for pattern in BLOCKING_REGEX): sys.exit("This PR is not ready for consumption.") -g = Github(os.environ.get("GITHUB_TOKEN")) -repo = g.get_repo("pulp/pulp-cli{{ cookiecutter.__app_label_suffix }}") - def check_status(issue: str) -> None: + {%- if cookiecutter.repository.startswith("https://github.com/") %} + from github import Github + + g = Github(os.environ.get("GITHUB_TOKEN")) + repo = g.get_repo("{{ cookiecutter.repository[19:] }}") + gi = repo.get_issue(int(issue)) if gi.pull_request: sys.exit(f"Error: issue #{issue} is a pull request.") if gi.closed_at: sys.exit(f"Error: issue #{issue} is closed.") + {%- else %} + pass + {%- endif %} def check_changelog(issue: str) -> None: diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update index 1784e188a..50cca73f9 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/pyproject.toml.update @@ -28,6 +28,7 @@ test = [ "secretstorage>=3.5.0", "trustme>=1.1.0,<1.3", ] +{%- if cookiecutter.glue %} [tool.uv.sources] # This section is managed by the cookiecutter templates. @@ -36,6 +37,7 @@ pulp-glue{{ cookiecutter.__app_label_suffix }} = { workspace = true } [tool.uv.workspace] # This section is managed by the cookiecutter templates. members = ["pulp-glue{{ cookiecutter.__app_label_suffix }}"] +{%- endif %} [tool.uv.build-backend] # This section is managed by the cookiecutter templates. From 2e98f6712b590d73d9aec78b0db404d13a3b5ae0 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 15 Jun 2026 10:30:46 +0200 Subject: [PATCH 2/2] Apply cookiecutter --- .ci/scripts/validate_commit_message.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.ci/scripts/validate_commit_message.py b/.ci/scripts/validate_commit_message.py index 998707aeb..7e678c178 100644 --- a/.ci/scripts/validate_commit_message.py +++ b/.ci/scripts/validate_commit_message.py @@ -12,7 +12,6 @@ from pathlib import Path import tomllib -from github import Github with Path("pyproject.toml").open("rb") as fp: PYPROJECT_TOML = tomllib.load(fp) @@ -36,11 +35,13 @@ if any(re.match(pattern, message) for pattern in BLOCKING_REGEX): sys.exit("This PR is not ready for consumption.") -g = Github(os.environ.get("GITHUB_TOKEN")) -repo = g.get_repo("pulp/pulp-cli") - def check_status(issue: str) -> None: + from github import Github + + g = Github(os.environ.get("GITHUB_TOKEN")) + repo = g.get_repo("pulp/pulp-cli") + gi = repo.get_issue(int(issue)) if gi.pull_request: sys.exit(f"Error: issue #{issue} is a pull request.")