If prefix is set on a remote, the fetch refspec for that remote becomes +refs/heads/<prefix>/*:refs/remotes/<name>/<prefix>/*.
If prefix is absent (current behavior), the default refspec +refs/heads/*:refs/remotes/<name>/* is used.
Top-level branchNamePrefix continues to apply to a remote named "origin" for backwards compatibility with url= shorthand.
Migration path
After this change:
hermes_infra.py after PR #8 — already drops branchNamePrefix, no change needed.
All migration PRs (#26 gmail_mcp, #28 hermes, future #19 gitea.py) — add "prefix": "ansible" (or "immoscout") to each remote entry.
Existing url= configs (single-remote, with branchNamePrefix) — keep working unchanged.
Acceptance criteria
GitClone(remotes=[{"name": "x", "url": "...", "prefix": "ansible"}]) fetches only ansible/* branches from remote x.
GitClone(remotes=[{"name": "x", "url": "..."}]) (no prefix) fetches all branches — backwards-compatible.
GitClone(url="...", branchNamePrefix="ansible") (single-remote shorthand) still applies prefix to the implicit origin remote.
Mixed: some remotes with prefix, some without — each behaves independently.
Test coverage: tests/test_git_integration.py gets a new test case exercising the per-remote prefix.
PR #28 can be re-opened with the new contract (replace branchNamePrefix="ansible" with "prefix": "ansible" per remote).
Out of scope
Changing the branchNamePrefix semantics globally (e.g. applying to all remotes by default).
Changing git_clone URL conventions.
Implementation hint
The change is localized to backend/steps/git.py:106-110. The refspec building loop needs to consider per-remote prefix. The dict normalization (__init__) should validate that prefix is a string when present.
## Add per-remote branch prefix filtering for multi-remote `GitClone`
### Context
`GitClone.branchNamePrefix` is silently ignored when constructed with the explicit `remotes=[...]` form (verified in `backend/steps/git.py:106`):
```python
if remote_name == "origin" and self.branchNamePrefix != "":
config.set_value('remote "origin"', "fetch",
f"+refs/heads/{self.branchNamePrefix}/*:refs/remotes/origin/{self.branchNamePrefix}/*")
```
The prefix only fires when a remote is named `"origin"`. The `remotes=` form passes names through verbatim, so configs like:
```python
clone = GitClone(remotes=[
{"name": "github", "url": "..."},
{"name": "gitea_hermes", "url": "..."},
{"name": "gitea_admin", "url": "..."},
], branchNamePrefix="ansible")
```
…set the prefix on the clone but **never apply it**. All remotes fetch their full refset.
This blocks PR #28 (hermes.py migration) and any future multi-remote config that wants to keep its branch list scoped.
### Proposed API
Extend each remote entry to optionally carry a `prefix`:
```python
clone = GitClone(remotes=[
{"name": "github", "url": "...", "prefix": "ansible"},
{"name": "gitea_hermes", "url": "...", "prefix": "ansible"},
{"name": "gitea_admin", "url": "...", "prefix": "ansible"},
])
```
Behavior:
- If `prefix` is set on a remote, the fetch refspec for that remote becomes `+refs/heads/<prefix>/*:refs/remotes/<name>/<prefix>/*`.
- If `prefix` is absent (current behavior), the default refspec `+refs/heads/*:refs/remotes/<name>/*` is used.
- Top-level `branchNamePrefix` continues to apply to a remote named `"origin"` for backwards compatibility with `url=` shorthand.
### Migration path
After this change:
- `hermes_infra.py` after PR #8 — already drops `branchNamePrefix`, no change needed.
- All migration PRs (#26 gmail_mcp, #28 hermes, future #19 gitea.py) — add `"prefix": "ansible"` (or `"immoscout"`) to each remote entry.
- Existing `url=` configs (single-remote, with `branchNamePrefix`) — keep working unchanged.
### Acceptance criteria
1. `GitClone(remotes=[{"name": "x", "url": "...", "prefix": "ansible"}])` fetches only `ansible/*` branches from remote `x`.
2. `GitClone(remotes=[{"name": "x", "url": "..."}])` (no prefix) fetches all branches — backwards-compatible.
3. `GitClone(url="...", branchNamePrefix="ansible")` (single-remote shorthand) still applies prefix to the implicit `origin` remote.
4. Mixed: some remotes with prefix, some without — each behaves independently.
5. Test coverage: `tests/test_git_integration.py` gets a new test case exercising the per-remote prefix.
6. PR #28 can be re-opened with the new contract (replace `branchNamePrefix="ansible"` with `"prefix": "ansible"` per remote).
### Out of scope
- Changing the `branchNamePrefix` semantics globally (e.g. applying to all remotes by default).
- Changing `git_clone` URL conventions.
### Implementation hint
The change is localized to `backend/steps/git.py:106-110`. The refspec building loop needs to consider per-remote `prefix`. The dict normalization (`__init__`) should validate that `prefix` is a string when present.
Refs PR #28
Blocks #18 (parent migration ticket)
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.
Add per-remote branch prefix filtering for multi-remote
GitCloneContext
GitClone.branchNamePrefixis 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:…set the prefix on the clone but never apply it. All remotes fetch their full refset.
This blocks PR #28 (hermes.py migration) and any future multi-remote config that wants to keep its branch list scoped.
Proposed API
Extend each remote entry to optionally carry a
prefix:Behavior:
prefixis set on a remote, the fetch refspec for that remote becomes+refs/heads/<prefix>/*:refs/remotes/<name>/<prefix>/*.prefixis absent (current behavior), the default refspec+refs/heads/*:refs/remotes/<name>/*is used.branchNamePrefixcontinues to apply to a remote named"origin"for backwards compatibility withurl=shorthand.Migration path
After this change:
hermes_infra.pyafter PR #8 — already dropsbranchNamePrefix, no change needed."prefix": "ansible"(or"immoscout") to each remote entry.url=configs (single-remote, withbranchNamePrefix) — keep working unchanged.Acceptance criteria
GitClone(remotes=[{"name": "x", "url": "...", "prefix": "ansible"}])fetches onlyansible/*branches from remotex.GitClone(remotes=[{"name": "x", "url": "..."}])(no prefix) fetches all branches — backwards-compatible.GitClone(url="...", branchNamePrefix="ansible")(single-remote shorthand) still applies prefix to the implicitoriginremote.tests/test_git_integration.pygets a new test case exercising the per-remote prefix.branchNamePrefix="ansible"with"prefix": "ansible"per remote).Out of scope
branchNamePrefixsemantics globally (e.g. applying to all remotes by default).git_cloneURL conventions.Implementation hint
The change is localized to
backend/steps/git.py:106-110. The refspec building loop needs to consider per-remoteprefix. The dict normalization (__init__) should validate thatprefixis a string when present.Refs PR #28
Blocks #18 (parent migration ticket)