From 849ba242a9056374b7a237a0d0554d426356f3d2 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 21 Dec 2025 17:23:22 -0800 Subject: [PATCH] fix(mq): push branch to origin before creating MR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: Both `gt done` and `gt mq submit` were creating MR records without pushing the branch to origin first. When polecat worktrees were deleted, the unpushed branches were lost forever. This caused 12 MQ items to become orphaned - merge requests existed but their branches had vanished. The fix adds a mandatory `git push origin ` before creating the MR record. If push fails, the MR is not created. Fixes: gt-aqku 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/done.go | 8 ++++++++ internal/cmd/mq_submit.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/cmd/done.go b/internal/cmd/done.go index 985890ad..1e6ba9ce 100644 --- a/internal/cmd/done.go +++ b/internal/cmd/done.go @@ -111,6 +111,14 @@ func runDone(cmd *cobra.Command, args []string) error { // Build title title := fmt.Sprintf("Merge: %s", issueID) + // CRITICAL: Push branch to origin BEFORE creating MR + // Without this, the worktree can be deleted and the branch lost forever + fmt.Printf("Pushing branch to origin...\n") + if err := g.Push("origin", branch, false); err != nil { + return fmt.Errorf("pushing branch to origin: %w", err) + } + fmt.Printf("%s Branch pushed to origin/%s\n", style.Bold.Render("✓"), branch) + // Build description with MR fields mrFields := &beads.MRFields{ Branch: branch, diff --git a/internal/cmd/mq_submit.go b/internal/cmd/mq_submit.go index 68337c71..b6ce7111 100644 --- a/internal/cmd/mq_submit.go +++ b/internal/cmd/mq_submit.go @@ -133,6 +133,14 @@ func runMqSubmit(cmd *cobra.Command, args []string) error { // Build title title := fmt.Sprintf("Merge: %s", issueID) + // CRITICAL: Push branch to origin BEFORE creating MR + // Without this, the worktree can be deleted and the branch lost forever + fmt.Printf("Pushing branch to origin...\n") + if err := g.Push("origin", branch, false); err != nil { + return fmt.Errorf("pushing branch to origin: %w", err) + } + fmt.Printf("%s Branch pushed to origin/%s\n", style.Bold.Render("✓"), branch) + // Build description with MR fields mrFields := &beads.MRFields{ Branch: branch,