[brencher] branchNamePrefix silently ignored in multi-remote configs (blocks #28) #29

Open
opened 2026-08-30 22:22:14 +02:00 by hermes · 0 comments
Contributor

branchNamePrefix is silently ignored in multi-remote configs

Discovery

When GitClone is constructed with remotes=[{name, url}, ...] instead of url="...", the legacy branchNamePrefix argument becomes a silent no-op unless at least one of the explicit remotes is named "origin".

Code: backend/steps/git.py:106

if remote_name == "origin" and self.branchNamePrefix != "":
    config.set_value('remote "origin"', "fetch",
        f"+refs/heads/{self.branchNamePrefix}/*:refs/remotes/origin/{self.branchNamePrefix}/*")

Only fires when a remote is named "origin". The url= shorthand (GitClone(url="...")) auto-renames the first entry to "origin" (line 56-58), so single-remote configs work as before. The explicit remotes= form passes names through verbatim — so a config like:

clone = GitClone(remotes=[
    {"name": "github",       "url": "..."},
    {"name": "gitea_hermes", "url": "..."},
    {"name": "gitea_admin",  "url": "..."},
], branchNamePrefix="ansible")

…sets branchNamePrefix="ansible" on the clone but never applies it. All three remotes fetch their full refset.

Why this matters

The whole point of branchNamePrefix was to scope what brencher sees — only branches matching ansible/* (or immoscout/* for gmail_mcp). Without the filter, brencher sees every branch from every remote, including noise:

  • Work branches from other stacks
  • PR branches with no relation to this stack
  • Default branches that should be invisible (main vs ansible/master)

For configs that previously relied on the prefix to keep state clean (e.g. immich.py, hermes.py, gitea.py, gmail_mcp.py), switching to multi-remote form drops the filter silently. The behavior change may not surface in tests because all branches are still valid refs — but the UI, the state file, and the candidate list for CheckoutMerged all get noisier.

Concrete symptom

/opt/data/work/thread-16-Alex-InfraAlexBot/brencher/backend/configs/hermes.py in PR #28:

clone = GitClone(remotes=[
    {"name": "github",       "url": "https://github.com/rudolf1/uber_backup.git"},
    {"name": "gitea_hermes", "url": "https://gitea.rudolf.keenetic.link/hermes/ansible"},
    {"name": "gitea_admin",  "url": "https://gitea.rudolf.keenetic.link/admin/ansible"},
], branchNamePrefix="ansible")

branchNamePrefix="ansible" is set but not applied — no remote is named origin. brencher fetches all branches from all three remotes.

What's currently shipped

  • hermes_infra.py after PR #8 already drops branchNamePrefix (uses only gitea remotes, both explicitly named) — works as intended.
  • brencher.py / brencher2.py — same: no prefix, no issue.
  • torrserv_proxy.py after PR #23 — branchNamePrefix was never set there.
  • All open migration PRs (#26 gmail_mcp, #28 hermes, planned #19 gitea.py, planned immich) carry branchNamePrefix and silently lose it.

Options

  1. Document the limitation, drop branchNamePrefix everywhere it no longer applies (PR #28 fix, all future PRs). Simplest, no behavior change in practice (because prefix was already broken in multi-remote).
  2. Change the rule to apply prefix per-remote when set: extend the dict to {"name": "...", "url": "...", "prefix": "ansible"}, or accept a top-level branchPrefixes mapping. More work, real filtering restored.
  3. Apply prefix to every remote (not just origin). Backwards-compatible for callers that only set one remote named origin, but in the multi-remote world it's surprising — not every remote's branches should be filtered the same way.

Acceptance criteria

A decision on which way to go, plus the corresponding follow-ups:

  • If option 1: this ticket tracks updating the open migration PRs (#26, #28, future #19) and the merged-but-still-prefixed configs (immich.py, gitea.py, etc.).
  • If option 2 or 3: a follow-up brencher PR implements the new contract, and a coordinated admin/brencher PR switches configs to it.

Blocking

  • #28 (PR: feat(configs): point hermes at gitea admin/hermes ansible repos) — cannot merge until this is resolved, because the branchNamePrefix="ansible" in the PR is misleading: readers will think it filters, but it doesn't.

Refs PR #28
Part of #18 (parent migration ticket)

## `branchNamePrefix` is silently ignored in multi-remote configs ### Discovery When `GitClone` is constructed with `remotes=[{name, url}, ...]` instead of `url="..."`, the legacy `branchNamePrefix` argument becomes a silent no-op unless at least one of the explicit remotes is named `"origin"`. Code: `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}/*") ``` Only fires when a remote is named `"origin"`. The `url=` shorthand (`GitClone(url="...")`) auto-renames the first entry to `"origin"` (line 56-58), so single-remote configs work as before. The explicit `remotes=` form passes names through verbatim — so a config like: ```python clone = GitClone(remotes=[ {"name": "github", "url": "..."}, {"name": "gitea_hermes", "url": "..."}, {"name": "gitea_admin", "url": "..."}, ], branchNamePrefix="ansible") ``` …sets `branchNamePrefix="ansible"` on the clone but **never applies it**. All three remotes fetch their full refset. ### Why this matters The whole point of `branchNamePrefix` was to scope what brencher sees — only branches matching `ansible/*` (or `immoscout/*` for `gmail_mcp`). Without the filter, brencher sees every branch from every remote, including noise: - Work branches from other stacks - PR branches with no relation to this stack - Default branches that should be invisible (`main` vs `ansible/master`) For configs that previously relied on the prefix to keep state clean (e.g. `immich.py`, `hermes.py`, `gitea.py`, `gmail_mcp.py`), switching to multi-remote form drops the filter silently. The behavior change may not surface in tests because all branches are still valid refs — but the UI, the state file, and the candidate list for `CheckoutMerged` all get noisier. ### Concrete symptom `/opt/data/work/thread-16-Alex-InfraAlexBot/brencher/backend/configs/hermes.py` in PR #28: ```python clone = GitClone(remotes=[ {"name": "github", "url": "https://github.com/rudolf1/uber_backup.git"}, {"name": "gitea_hermes", "url": "https://gitea.rudolf.keenetic.link/hermes/ansible"}, {"name": "gitea_admin", "url": "https://gitea.rudolf.keenetic.link/admin/ansible"}, ], branchNamePrefix="ansible") ``` `branchNamePrefix="ansible"` is set but **not applied** — no remote is named `origin`. brencher fetches all branches from all three remotes. ### What's currently shipped - `hermes_infra.py` after PR #8 already drops `branchNamePrefix` (uses only gitea remotes, both explicitly named) — works as intended. - `brencher.py` / `brencher2.py` — same: no prefix, no issue. - `torrserv_proxy.py` after PR #23 — `branchNamePrefix` was never set there. - All open migration PRs (#26 `gmail_mcp`, #28 `hermes`, planned #19 `gitea.py`, planned immich) carry `branchNamePrefix` and silently lose it. ### Options 1. **Document the limitation**, drop `branchNamePrefix` everywhere it no longer applies (PR #28 fix, all future PRs). Simplest, no behavior change in practice (because prefix was already broken in multi-remote). 2. **Change the rule to apply prefix per-remote when set**: extend the dict to `{"name": "...", "url": "...", "prefix": "ansible"}`, or accept a top-level `branchPrefixes` mapping. More work, real filtering restored. 3. **Apply prefix to every remote** (not just `origin`). Backwards-compatible for callers that only set one remote named `origin`, but in the multi-remote world it's surprising — not every remote's branches should be filtered the same way. ### Acceptance criteria A decision on which way to go, plus the corresponding follow-ups: - If option 1: this ticket tracks updating the open migration PRs (#26, #28, future #19) and the merged-but-still-prefixed configs (`immich.py`, `gitea.py`, etc.). - If option 2 or 3: a follow-up brencher PR implements the new contract, and a coordinated admin/brencher PR switches configs to it. ### Blocking - #28 (PR: `feat(configs): point hermes at gitea admin/hermes ansible repos`) — cannot merge until this is resolved, because the `branchNamePrefix="ansible"` in the PR is misleading: readers will think it filters, but it doesn't. Refs PR #28 Part of #18 (parent migration ticket)
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/brencher#29