From 61f8c80e35f4173af4016716b1a2735768a971ab Mon Sep 17 00:00:00 2001 From: capable Date: Thu, 1 Jan 2026 16:09:54 -0800 Subject: [PATCH] fix(done): Verify branch has commits ahead of main before MR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add CommitsAhead check after BranchPushedToRemote to prevent stale branches (pushed but 0 commits ahead of main) from being submitted to the merge queue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 (gt-fpv2p) --- internal/cmd/done.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/cmd/done.go b/internal/cmd/done.go index 86ea61cd..5bfd7c9d 100644 --- a/internal/cmd/done.go +++ b/internal/cmd/done.go @@ -138,6 +138,15 @@ func runDone(cmd *cobra.Command, args []string) error { return fmt.Errorf("branch has %d unpushed commit(s); run 'git push -u origin %s' first", unpushedCount, branch) } + // Check that branch has commits ahead of main (prevents submitting stale branches) + aheadCount, err := g.CommitsAhead("main", branch) + if err != nil { + return fmt.Errorf("checking commits ahead of main: %w", err) + } + if aheadCount == 0 { + return fmt.Errorf("branch '%s' has 0 commits ahead of main; nothing to merge", branch) + } + if issueID == "" { return fmt.Errorf("cannot determine source issue from branch '%s'; use --issue to specify", branch) }