Skip to content

fix(pipeline): merge_to_main pushed HEAD, not the task's branch - #280

Merged
ANonABento merged 2 commits into
mainfrom
merge-to-main-refspec
Aug 22, 2026
Merged

fix(pipeline): merge_to_main pushed HEAD, not the task's branch#280
ANonABento merged 2 commits into
mainfrom
merge-to-main-refspec

Conversation

@ANonABento

Copy link
Copy Markdown
Owner

The worst one this session, because it reported success while doing nothing.

The bug

git push origin HEAD:refs/heads/main

…run from resolve_working_dir. That is the task's worktree when it has one, and the shared workspace checkout when it doesn't — which happens routinely, since terminal-column cleanup removes the worktree while branch_name survives on the row.

So HEAD was whatever the user happened to have checked out:

  • Repo on mainHEAD:refs/heads/main is a no-op push that succeeds. The trigger then logs Pushed <branch> to origin/main having merged nothing.
  • Repo on any other branch → it publishes unrelated working state to main.

Both are silent. The success log made the first actively misleading — I only caught it because I checked git ls-remote rather than trusting the log.

Reproduction, against a real bare origin

Before:

origin/main BEFORE: 9b5a20453ce8
[merge_to_main] Pushed kaitencode/feature-x to origin/main   ← the log
origin/main AFTER : 9b5a20453ce8                             ← unchanged
version.js on origin/main: NO

After:

origin/main BEFORE: 9b5a20453ce8
origin/main AFTER : d2e39ea4325c
version.js on origin/main: YES — merge landed

The fix

Push the task's branch by name — the same branch the function validates at the top and names in that log line. Extracted as merge_to_main_refspec so a test pins the one thing that must not regress (that it never names HEAD).

execute_auto_merge was checked for the same pattern and does not share it — it passes the branch name through explicitly.

Worth flagging separately

merge_to_main is backend-only: it's absent from the frontend ActionType union, so no UI can configure a column to use it. Noted on the roadmap rather than fixed here — that's a feature decision, not a bug fix.

Checks

cargo clippy -D warnings · cargo test --lib 569 (+1) · tsc · eslint · vitest 444.

It ran `git push origin HEAD:refs/heads/main` from `resolve_working_dir`.
That is the task's worktree when it has one — and the **shared workspace
checkout** when it doesn't, which happens routinely: terminal-column cleanup
removes the worktree while `branch_name` survives on the row.

So `HEAD` was whatever the user happened to have checked out. With the repo
sitting on `main`, `HEAD:refs/heads/main` is a no-op push that *succeeds* —
the trigger then logged "Pushed <branch> to origin/main" having merged
nothing at all. On any other branch it would have published unrelated
working state to main.

Both failure modes are silent. The success log made the first one actively
misleading.

Now pushes the task's branch by name — the same branch the function
validates at the top and names in that log line. Extracted as
`merge_to_main_refspec` so a test pins the one thing that must not regress.

Verified against a real bare origin: before the fix, origin/main stayed at
the initial commit and the branch's file never appeared on it despite the
success log; after, origin/main advanced and carries it.

`execute_auto_merge` was checked for the same pattern and does not share it
— it passes the branch name through explicitly.

Worth noting separately: `merge_to_main` is backend-only. It is absent from
the frontend `ActionType` union, so no UI can configure a column to use it.
@ANonABento
ANonABento merged commit c3c65c4 into main Aug 22, 2026
3 checks passed
@ANonABento
ANonABento deleted the merge-to-main-refspec branch August 22, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant