fix(mq): push branch to origin before creating MR

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 <branch>` 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 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-21 17:23:22 -08:00
parent 7badab8a71
commit 849ba242a9
2 changed files with 16 additions and 0 deletions

View File

@@ -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,

View File

@@ -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,