From 5d3fc17cd3ca59d361283a1a82940ad82e7e0f38 Mon Sep 17 00:00:00 2001 From: Cas Teeuwen Date: Tue, 15 Sep 2026 08:21:18 +0200 Subject: [PATCH 1/5] feat(template): make XomniaAi new default github username --- copier.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copier.yml b/copier.yml index ec19824..a969846 100644 --- a/copier.yml +++ b/copier.yml @@ -29,7 +29,7 @@ author_email: github_username: type: str help: GitHub username or organization - default: "{{ author_name | lower | replace(' ', '') }}" + default: "XomniaAi" project_name: type: str From 50c8ca0742c3bc26aea0dd0b758de6290be1b7fe Mon Sep 17 00:00:00 2001 From: Cas Teeuwen Date: Tue, 15 Sep 2026 09:03:45 +0200 Subject: [PATCH 2/5] feat(git): add push_to_github option Adds a project_github_name which uses dashified slug name, to follow convention --- copier.yml | 16 ++++++++++++++++ template/README.md.jinja | 4 ++-- template/pyproject.toml.jinja | 4 ++-- tests/test_template.py | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/copier.yml b/copier.yml index a969846..0a90b48 100644 --- a/copier.yml +++ b/copier.yml @@ -13,6 +13,10 @@ _tasks: - "git checkout -b main" - "uv sync" - "uv run pre-commit install" + - "git add -A" + - "git commit -m \"chore: initial commit\"" + - command: gh repo create {{ github_username }}/{{ project_github_name }} --source=. --push --private + when: "{{ push_to_github }}" # Questions @@ -53,6 +57,11 @@ project_slug: and underscores only, and it may not start with a digit. {% endif %} +project_github_name: + type: str + default: "{{ project_slug | lower | replace('_', '-') }}" + when: false + project_short_description: type: str help: A short description of the project @@ -81,3 +90,10 @@ include_hexagonal: adapters layers with an example slice, plus import-linter contracts that enforce the layer boundaries. default: true + +push_to_github: + type: bool + help: >- + Push the repository to GitHub. Auto-applies standard branch protection rules + standard for trunk-based development. (e.g. one main branch) + default: true \ No newline at end of file diff --git a/template/README.md.jinja b/template/README.md.jinja index 2912efb..7f983cf 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -1,12 +1,12 @@ # {{ project_name }} -[![Tests](https://github.com/{{ github_username }}/{{ project_slug }}/actions/workflows/ci.yaml/badge.svg)](https://github.com/{{ github_username }}/{{ project_slug }}/actions/workflows/ci.yaml) +[![Tests](https://github.com/{{ github_username }}/{{ project_github_name }}/actions/workflows/ci.yaml/badge.svg)](https://github.com/{{ github_username }}/{{ project_github_name }}/actions/workflows/ci.yaml) [![PyPI version](https://badge.fury.io/py/{{ project_slug | replace('_', '-') }}.svg)](https://pypi.org/project/{{ project_slug | replace('_', '-') }}/) {{ project_short_description }} -Original repository: [https://github.com/{{ github_username }}/{{ project_slug }}](https://github.com/{{ github_username }}/{{ project_slug }}) +Original repository: [https://github.com/{{ github_username }}/{{ project_github_name }}](https://github.com/{{ github_username }}/{{ project_github_name }}) {% if include_hexagonal -%} diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index c0f0ae2..ef8d00a 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -25,8 +25,8 @@ dependencies = [ ] [project.urls] -Homepage = "https://github.com/{{ github_username }}/{{ project_slug }}" -Repository = "https://github.com/{{ github_username }}/{{ project_slug }}" +Homepage = "https://github.com/{{ github_username }}/{{ project_github_name }}" +Repository = "https://github.com/{{ github_username }}/{{ project_github_name }}" [tool.hatch.build.targets.wheel] packages = ["src/{{ project_slug }}"] diff --git a/tests/test_template.py b/tests/test_template.py index e971b86..2bb44d6 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -47,6 +47,7 @@ def _triggers(workflow: dict) -> dict: "project_short_description": "A test project.", "version": "0.1.0", "license": "MIT", + "push_to_github": False } @@ -327,7 +328,7 @@ def test_default_slug_is_valid_package_name(tmp_path): copier.run_copy( src_path=str(TEMPLATE_ROOT), dst_path=str(dst), - data={"author_name": "Joe Doe", "author_email": "joe@example.com"}, + data={"author_name": "Joe Doe", "author_email": "joe@example.com", "push_to_github": False}, defaults=True, unsafe=True, vcs_ref="HEAD", From 92b4a47f6909ad293b8ae407b5e17e954f3923f5 Mon Sep 17 00:00:00 2001 From: Cas Teeuwen Date: Tue, 15 Sep 2026 16:49:47 +0200 Subject: [PATCH 3/5] feat(git): add branch protection rules --- copier.yml | 2 ++ template/branch_protection_rules.json | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 template/branch_protection_rules.json diff --git a/copier.yml b/copier.yml index 0a90b48..6e98c86 100644 --- a/copier.yml +++ b/copier.yml @@ -17,6 +17,8 @@ _tasks: - "git commit -m \"chore: initial commit\"" - command: gh repo create {{ github_username }}/{{ project_github_name }} --source=. --push --private when: "{{ push_to_github }}" + - command: "gh api --method PUT -H \"Accept: application/vnd.github+json\" repos/{{ github_username }}/{{ project_github_name }}/branches/main/protection --input branch_protection_rules.json" + when: "{{ push_to_github }}" # Questions diff --git a/template/branch_protection_rules.json b/template/branch_protection_rules.json new file mode 100644 index 0000000..6984163 --- /dev/null +++ b/template/branch_protection_rules.json @@ -0,0 +1,19 @@ +{ + "allow_deletions": false, + "allow_force_pushes": false, + "enforce_admins": true, + "required_linear_history": false, + "required_pull_request_reviews": { + "dismiss_stale_reviews": true, + "require_code_owner_reviews": false, + "require_last_push_approval": true, + "required_approving_review_count": 1 + }, + "required_status_checks": { + "contexts": [ + "ci-gate" + ], + "strict": true + }, + "restrictions": null +} From aed57564e1e073a733a6cb73b33fd4e872465b69 Mon Sep 17 00:00:00 2001 From: Cas Teeuwen Date: Tue, 15 Sep 2026 17:02:50 +0200 Subject: [PATCH 4/5] fix(ci): set example user --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 32fe862..e1eed44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,6 +24,10 @@ jobs: uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install dependencies run: uv sync + - name: Set git identity + run: | + git config --global user.email "ci-example-user@xomnia.com" + git config --global user.name "CI Example User" - name: Run pytest run: uv run pytest # Single aggregate check to require in the branch ruleset. It depends on From 09dc767502551a9ae91aa3a29e801f7f8102d9b7 Mon Sep 17 00:00:00 2001 From: Cas Teeuwen Date: Wed, 16 Sep 2026 09:50:37 +0200 Subject: [PATCH 5/5] fix(git): remove branch protection rules after apply --- copier.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/copier.yml b/copier.yml index 6e98c86..6ac0de2 100644 --- a/copier.yml +++ b/copier.yml @@ -13,12 +13,13 @@ _tasks: - "git checkout -b main" - "uv sync" - "uv run pre-commit install" - - "git add -A" + - "git add --all -- :!branch_protection_rules.json" - "git commit -m \"chore: initial commit\"" - command: gh repo create {{ github_username }}/{{ project_github_name }} --source=. --push --private when: "{{ push_to_github }}" - command: "gh api --method PUT -H \"Accept: application/vnd.github+json\" repos/{{ github_username }}/{{ project_github_name }}/branches/main/protection --input branch_protection_rules.json" when: "{{ push_to_github }}" + - rm branch_protection_rules.json # Questions