Allow naming each GitClone remote explicitly #3

Merged
admin merged 7 commits from hermes/brencher:named-remotes into main 2026-08-25 18:53:14 +02:00
Contributor

Implements the review comment on #2:

I would like to give names for remotes

Summary

Adds a remotes=[{"name": ..., "url": ...}, ...] constructor to GitClone so the config author controls how each URL maps to a git remote. The existing url=str / url=[str] shorthand is kept as backward-compatible (positional list still maps to origin, repo1, repo2, ...), so PR #2's test_git_clone_multiple_urls continues to pass.

Changes

  • backend/steps/git.py — GitClone.__init__ now accepts either url= or remotes=. With remotes=, every entry must carry a non-empty unique name and url; duplicates and missing fields raise ValueError. The constructor rejects passing both or neither. self.remotes becomes the source of truth; self.urls is a derived list (kept for any introspection). CheckoutMerged.find_desired_commits falls back to the configured primary remote instead of the hardcoded 'origin' when a branch key has no remote prefix, so configs that don't name a remote origin still work.
  • backend/configs/brencher.py, brencher2.py — switch from positional list to named remotes github, gitea_admin, gitea_hermes.
  • tests/test_git_integration.py — adds test_git_clone_named_remotes (asserts the user-chosen names appear verbatim and origin/repo1 do not leak) and test_git_clone_remotes_validation (covers every rejection path: empty list, missing/empty name, missing/empty url, duplicate name, both-kwargs, no-kwargs).

Diff vs #2

backend/configs/brencher.py    |  8 ++---
backend/configs/brencher2.py   |  8 ++---
backend/steps/git.py           | 76 +++++++++++++++++++++++++++++++++++++++-------
tests/test_git_integration.py  | 75 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 147 insertions(+), 20 deletions(-)

Targets admin/multiple_remotes so this lands on top of #2. After #2 merges, this is a clean follow-up; if #2 is reworked, this branch will need a rebase.

Verification

  • python3 -m py_compile on all 4 changed files: clean.
  • AST-driven call-shape check: every GitClone(...) in both configs uses the new remotes= kwarg with exactly {github, gitea_admin, gitea_hermes}; no positional-list leftover in configs.
  • Executed the new __init__ in isolation against a stubbed super() and exercised 12 cases: 3 OK shapes (url=str, url=[..], remotes=[valid]) and 9 rejection shapes (empty list, missing/empty name, missing/empty url, duplicate name, both-kwargs, no-kwargs, non-dict entry). All 12 produced the asserted ValueError/TypeError with the expected message substring.
  • Could not run pytest in this sandbox (PyPI is blocked by the proxy and no pytest/gitpython is pre-installed). The two new tests and PR #2's existing test should be run in a real env before merge.
Implements the review comment on #2: > I would like to give names for remotes ## Summary Adds a `remotes=[{"name": ..., "url": ...}, ...]` constructor to `GitClone` so the config author controls how each URL maps to a git remote. The existing `url=str` / `url=[str]` shorthand is kept as backward-compatible (positional list still maps to `origin`, `repo1`, `repo2`, ...), so PR #2's `test_git_clone_multiple_urls` continues to pass. ## Changes - **`backend/steps/git.py`** — `GitClone.__init__` now accepts either `url=` or `remotes=`. With `remotes=`, every entry must carry a non-empty unique `name` and `url`; duplicates and missing fields raise `ValueError`. The constructor rejects passing both or neither. `self.remotes` becomes the source of truth; `self.urls` is a derived list (kept for any introspection). `CheckoutMerged.find_desired_commits` falls back to the configured primary remote instead of the hardcoded `'origin'` when a branch key has no remote prefix, so configs that don't name a remote `origin` still work. - **`backend/configs/brencher.py`, `brencher2.py`** — switch from positional list to named remotes `github`, `gitea_admin`, `gitea_hermes`. - **`tests/test_git_integration.py`** — adds `test_git_clone_named_remotes` (asserts the user-chosen names appear verbatim and `origin`/`repo1` do not leak) and `test_git_clone_remotes_validation` (covers every rejection path: empty list, missing/empty name, missing/empty url, duplicate name, both-kwargs, no-kwargs). ## Diff vs #2 ``` backend/configs/brencher.py | 8 ++--- backend/configs/brencher2.py | 8 ++--- backend/steps/git.py | 76 +++++++++++++++++++++++++++++++++++++++------- tests/test_git_integration.py | 75 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 147 insertions(+), 20 deletions(-) ``` Targets `admin/multiple_remotes` so this lands on top of #2. After #2 merges, this is a clean follow-up; if #2 is reworked, this branch will need a rebase. ## Verification - `python3 -m py_compile` on all 4 changed files: clean. - AST-driven call-shape check: every `GitClone(...)` in both configs uses the new `remotes=` kwarg with exactly `{github, gitea_admin, gitea_hermes}`; no positional-list leftover in configs. - Executed the new `__init__` in isolation against a stubbed `super()` and exercised 12 cases: 3 OK shapes (url=str, url=[..], remotes=[valid]) and 9 rejection shapes (empty list, missing/empty name, missing/empty url, duplicate name, both-kwargs, no-kwargs, non-dict entry). All 12 produced the asserted `ValueError`/`TypeError` with the expected message substring. - Could not run `pytest` in this sandbox (PyPI is blocked by the proxy and no `pytest`/`gitpython` is pre-installed). The two new tests and PR #2's existing test should be run in a real env before merge.
admin changed target branch from multiple_remotes to main 2026-08-23 19:51:55 +02:00
hermes changed target branch from main to multiple_remotes 2026-08-23 22:51:56 +02:00
hermes changed target branch from multiple_remotes to main 2026-08-23 22:54:06 +02:00
hermes added 3 commits 2026-08-23 22:54:06 +02:00
Adds a remotes=[{name,url}] constructor to GitClone so the config
author controls how each URL maps to a git remote. Implements the
review comment on PR #2 ("I would like to give names for remotes").

The url=str / url=list[str] shorthand stays supported for backward
compatibility (positional list still maps to origin, repo1, repo2, ...),
so PR #2's test_git_clone_multiple_urls keeps passing.

- backend/steps/git.py: GitClone.__init__ now accepts either url= or
  remotes=. The remotes= form requires every entry to carry a non-empty
  unique name and url; duplicates and missing fields raise ValueError.
  self.remotes is the source of truth; self.urls is a derived list.
  CheckoutMerged.find_desired_commits falls back to the configured
  primary remote instead of hardcoded 'origin' when a branch key has
  no remote prefix.
- backend/configs/brencher.py, brencher2.py: pass named remotes
  github, gitea_admin, gitea_hermes.
- tests/test_git_integration.py: add test_git_clone_named_remotes
  (asserts user-chosen names appear verbatim and origin/repo1 do not
  leak) and test_git_clone_remotes_validation (every rejection path).
hermes added 1 commit 2026-08-23 22:54:33 +02:00
test: trigger CI check via whitespace-only commit
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Successful in 44s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Successful in 44s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Successful in 41s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Successful in 37s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Successful in 42s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Successful in 44s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Failing after 1m51s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Failing after 1m47s
Python package / build (pip list, 3.12.3) (pull_request) Successful in 47s
Python package / build (pip list, 3.13) (pull_request) Successful in 41s
Python package / build (pip list, 3.14) (pull_request) Successful in 37s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Successful in 36s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Successful in 41s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Successful in 32s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Failing after 1m38s
Python package / tests (pytest, 3.12.3) (pull_request) Skipped
Python package / tests (pytest, 3.13) (pull_request) Skipped
Python package / tests (pytest, 3.14) (pull_request) Skipped
bfd31616f0
hermes added 1 commit 2026-08-23 23:06:34 +02:00
fix: drop unused mypy type:ignore on GitClone() no-kwargs test
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Canceled after 0s
Python package / build (pip list, 3.12.3) (pull_request) Canceled after 0s
Python package / build (pip list, 3.13) (pull_request) Canceled after 0s
Python package / build (pip list, 3.14) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.12.3) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.13) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.14) (pull_request) Canceled after 0s
692c298de0
The '# type: ignore[call-arg]' on GitClone() was a relic from the
original __init__ signature where all params were required. After
making url=/remotes= both optional with None defaults, GitClone()
with no kwargs is well-typed; mypy with warn_unused_ignores=True
correctly flags the now-redundant ignore comment. Remove it.
hermes added 1 commit 2026-08-23 23:39:16 +02:00
test: dedupe named-remotes test fixture
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Canceled after 0s
Python package / build (pip list, 3.12.3) (pull_request) Canceled after 0s
Python package / build (pip list, 3.13) (pull_request) Canceled after 0s
Python package / build (pip list, 3.14) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.12.3) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.13) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.14) (pull_request) Canceled after 0s
330b8f8537
The two fresh-repo setup blocks were line-for-line identical except
for the variable name. Extract a fresh_repo(prefix, message) helper
and use it twice. Also hoist 'import tempfile' to module top to match
the file's import style.

pytest tests/test_git_integration.py still passes (3/3).
mypy on tests/test_git_integration.py still clean (same single
pre-existing transitive error in backend/steps/step.py).
hermes added 1 commit 2026-08-23 23:43:09 +02:00
chore: drop CI-trigger breadcrumb and extract branch-ref resolver
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Canceled after 0s
Python package / build (pip list, 3.12.3) (pull_request) Canceled after 0s
Python package / build (pip list, 3.13) (pull_request) Canceled after 0s
Python package / build (pip list, 3.14) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.12.3) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.13) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.14) (pull_request) Canceled after 0s
29e3c42e5c
Two small cleanups, no behavior change:

- Remove the stray '# CI trigger check: trailing whitespace test'
  comment left over from the CI-trigger experiment; it's not
  documentation of the surrounding logic.
- Extract the (slash-or-no-slash) / (remote-exists-or-not) branch-key
  resolution into a module-level _resolve_branch_ref() helper, replacing
  four lines of nested conditionals in find_desired_commits with a
  single helper call.

pytest tests/test_git_integration.py: 15/15 passed in 6.51s.
mypy on the 4 changed files: same single pre-existing transitive
error as on main; zero new errors.
admin approved these changes 2026-08-25 18:52:10 +02:00
admin merged commit e5331745be into main 2026-08-25 18:53:14 +02:00
admin deleted branch named-remotes 2026-08-25 18:53:15 +02:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/brencher#3