fix(finish): report MERGED as success instead of failing on branch cleanup - #697
Conversation
…eanup `gx branch finish` could merge the PR and still exit 1. After the merge, cleanup runs `git branch -d` on the source branch, which requires an ancestor link to HEAD or full upstream coverage. A squash merge — the default here (`gh pr merge --squash`) — leaves neither once the remote branch is gone, so the refusal is the NORMAL post-merge outcome. It was fatal, while every other cleanup step only warns. Seen on #695: merge landed, branch had been rebased during finish, `branch -d` said "not fully merged", run ended "branchFinish command failed with status 1" and never said the merge had succeeded. That output invites a force-push to fix a merge that already landed. - announce `MERGED <source> -> <base>` + PR URL the moment the merge is confirmed, before any cleanup can bury it - downgrade a refused local-branch delete to a warning - when `branch -d` refuses, ask GitHub whether that exact head landed in a merged PR; force the delete only then, else keep the branch - when a branch is kept, drop --delete-branches/--delete-remote-branches from the follow-up prune, which uses `git branch -D` and would destroy exactly what was protected - report "kept source branch" vs the two existing "cleaned ..." wordings, both preserved verbatim Test suite failing set md5-identical to main (41 = 41); new regression test covers merge-lands-but-delete-refused. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Decision: APPROVE — 0 CRITICAL, 0 HIGH, 0 MEDIUM, 2 LOW. Caveat stated up front: this is a self-review by the change's author, not an independent one. The repo's automated review gate ( Makes a landed merge report as success. The root cause is that Verified the premise rather than assuming it: in an isolated repo, a squash merge leaves The force-delete is gated on GitHub's merged-PR record for that exact head SHA, not on a patch-id guess. That distinction matters: Behavior tested against the real extracted function, both directions:
Caught and fixed one self-inflicted regression mid-review: collapsing the two closing summaries lost the distinct LOW-1: LOW-2: when a branch is kept, the prune drops Tests: 845 total, 41 failing — failing set md5-identical to main ( |
Summary
Test plan