GitClone's top-level branchNamePrefix argument was silently ignored when constructed with the explicit remotes=[...] form (verified in backend/steps/git.py:106):
The prefix only fires when a remote is named "origin". The remotes= form passes names through verbatim, so configs like the open PR #28 set the prefix but never apply it — all branches from all remotes are fetched.
This PR extends the API: each remote entry now optionally accepts a prefix field. When set, the fetch refspec for that remote becomes scoped to <prefix>/* branches. Backwards-compatible — remotes without prefix keep the existing behavior, and url= shorthand with branchNamePrefix still works.
Each remote is independent — some can have prefix, others not.
Changes
backend/steps/git.py
__init__ (remotes= branch): validate prefix (string if set, reject non-string with ValueError), persist into the normalized entry. Empty string / None → no prefix applied (existing behavior).
progress() fetch loop: replace the single if remote_name == "origin" check with per-entry logic. Effective prefix = entry["prefix"] or (self.branchNamePrefix if remote_name == "origin" else ""). Apply refspec per remote when effective prefix is non-empty.
tests/test_git_integration.py
3 new tests in TestGitIntegration:
test_git_clone_remotes_per_remote_prefix — both remotes prefixed; only ansible/* branches visible, master is filtered out.
test_git_clone_remotes_mixed_prefix — one remote prefixed, one not; each behaves independently.
test_git_clone_remotes_prefix_validation — prefix=123 / prefix=["ansible"] raise ValueError; prefix="" and missing-prefix are accepted.
Existing test_git_clone_named_remotes continues to pass (verified — no behavior change for unprefixed remotes).
Test results
29 passed in ~13s
(18 in test_git_integration.py, 11 in test_dummy.py/test_caching_step.py/test_cached_env.py.)
Migration path
After merge:
Open migration PRs (#26 gmail_mcp, #28 hermes, planned #19 gitea.py) — switch from branchNamePrefix="ansible" to "prefix": "ansible" on each remote.
hermes_infra.py after PR #8 already drops branchNamePrefix, no change needed.
PR #28 — once this lands, hermes.py can drop the (currently misleading) top-level branchNamePrefix="ansible" and add "prefix": "ansible" per remote.
Refs #30
Blocks #28
Part of #18 (parent migration ticket)
## Summary
`GitClone`'s top-level `branchNamePrefix` argument was silently ignored when constructed with the explicit `remotes=[...]` form (verified in `backend/steps/git.py:106`):
```python
if remote_name == "origin" and self.branchNamePrefix != "":
# apply refspec
```
The prefix only fires when a remote is named `"origin"`. The `remotes=` form passes names through verbatim, so configs like the open PR #28 set the prefix but never apply it — all branches from all remotes are fetched.
This PR extends the API: each remote entry now optionally accepts a `prefix` field. When set, the fetch refspec for that remote becomes scoped to `<prefix>/*` branches. Backwards-compatible — remotes without `prefix` keep the existing behavior, and `url=` shorthand with `branchNamePrefix` still works.
## API
```python
clone = GitClone(remotes=[
{"name": "github", "url": "...", "prefix": "ansible"},
{"name": "gitea_hermes", "url": "...", "prefix": "ansible"},
{"name": "gitea_admin", "url": "...", "prefix": "ansible"},
])
```
Each remote is independent — some can have `prefix`, others not.
## Changes
### `backend/steps/git.py`
- `__init__` (`remotes=` branch): validate `prefix` (string if set, reject non-string with `ValueError`), persist into the normalized entry. Empty string / None → no prefix applied (existing behavior).
- `progress()` fetch loop: replace the single `if remote_name == "origin"` check with per-entry logic. Effective prefix = `entry["prefix"] or (self.branchNamePrefix if remote_name == "origin" else "")`. Apply refspec per remote when effective prefix is non-empty.
### `tests/test_git_integration.py`
3 new tests in `TestGitIntegration`:
- `test_git_clone_remotes_per_remote_prefix` — both remotes prefixed; only `ansible/*` branches visible, `master` is filtered out.
- `test_git_clone_remotes_mixed_prefix` — one remote prefixed, one not; each behaves independently.
- `test_git_clone_remotes_prefix_validation` — `prefix=123` / `prefix=["ansible"]` raise `ValueError`; `prefix=""` and missing-`prefix` are accepted.
Existing `test_git_clone_named_remotes` continues to pass (verified — no behavior change for unprefixed remotes).
## Test results
```
29 passed in ~13s
```
(18 in `test_git_integration.py`, 11 in `test_dummy.py`/`test_caching_step.py`/`test_cached_env.py`.)
## Migration path
After merge:
- Open migration PRs (#26 gmail_mcp, #28 hermes, planned #19 gitea.py) — switch from `branchNamePrefix="ansible"` to `"prefix": "ansible"` on each remote.
- `hermes_infra.py` after PR #8 already drops `branchNamePrefix`, no change needed.
- Existing `url=` configs (immich, gmail_mcp-old, hermes-old, registry, gitea-old) — unaffected.
## Unblocks
PR #28 — once this lands, hermes.py can drop the (currently misleading) top-level `branchNamePrefix="ansible"` and add `"prefix": "ansible"` per remote.
Refs #30
Blocks #28
Part of #18 (parent migration ticket)
GitClone's branchNamePrefix argument was silently ignored when constructed
with the explicit remotes= form unless one of the remotes was named
'origin'. Multi-remote configs (introduced in #3) cannot use 'origin'
because that name is taken by the auto-generated shorthand.
Extend each remote entry to optionally carry a 'prefix' field. When set,
the fetch refspec for that remote becomes
+refs/heads/<prefix>/*:refs/remotes/<name>/<prefix>/*
filtering branches at fetch time.
Backwards compatible: remotes without 'prefix' continue to fetch all
branches; url= shorthand with branchNamePrefix still applies the prefix
to the implicit 'origin' remote.
Closes#30
Blocks #28 (PR: hermes.py migration) — once merged, hermes.py can be
re-opened with 'prefix': 'ansible' per remote instead of the misleading
top-level branchNamePrefix.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
GitClone's top-levelbranchNamePrefixargument was silently ignored when constructed with the explicitremotes=[...]form (verified inbackend/steps/git.py:106):The prefix only fires when a remote is named
"origin". Theremotes=form passes names through verbatim, so configs like the open PR #28 set the prefix but never apply it — all branches from all remotes are fetched.This PR extends the API: each remote entry now optionally accepts a
prefixfield. When set, the fetch refspec for that remote becomes scoped to<prefix>/*branches. Backwards-compatible — remotes withoutprefixkeep the existing behavior, andurl=shorthand withbranchNamePrefixstill works.API
Each remote is independent — some can have
prefix, others not.Changes
backend/steps/git.py__init__(remotes=branch): validateprefix(string if set, reject non-string withValueError), persist into the normalized entry. Empty string / None → no prefix applied (existing behavior).progress()fetch loop: replace the singleif remote_name == "origin"check with per-entry logic. Effective prefix =entry["prefix"] or (self.branchNamePrefix if remote_name == "origin" else ""). Apply refspec per remote when effective prefix is non-empty.tests/test_git_integration.py3 new tests in
TestGitIntegration:test_git_clone_remotes_per_remote_prefix— both remotes prefixed; onlyansible/*branches visible,masteris filtered out.test_git_clone_remotes_mixed_prefix— one remote prefixed, one not; each behaves independently.test_git_clone_remotes_prefix_validation—prefix=123/prefix=["ansible"]raiseValueError;prefix=""and missing-prefixare accepted.Existing
test_git_clone_named_remotescontinues to pass (verified — no behavior change for unprefixed remotes).Test results
(18 in
test_git_integration.py, 11 intest_dummy.py/test_caching_step.py/test_cached_env.py.)Migration path
After merge:
branchNamePrefix="ansible"to"prefix": "ansible"on each remote.hermes_infra.pyafter PR #8 already dropsbranchNamePrefix, no change needed.url=configs (immich, gmail_mcp-old, hermes-old, registry, gitea-old) — unaffected.Unblocks
PR #28 — once this lands, hermes.py can drop the (currently misleading) top-level
branchNamePrefix="ansible"and add"prefix": "ansible"per remote.Refs #30
Blocks #28
Part of #18 (parent migration ticket)