feat(rig): Add --branch flag for custom default branch

Add --branch flag to `gt rig add` to specify a custom default branch
instead of auto-detecting from remote. This supports repositories that
use non-standard default branches like `develop` or `release`.

Changes:
- Add --branch flag to `gt rig add` command
- Store default_branch in rig config.json
- Propagate default branch to refinery, witness, daemon, and all commands
- Rename ensureMainBranch to ensureDefaultBranch for clarity
- Add Rig.DefaultBranch() method for consistent access
- Update crew/manager.go and swarm/manager.go to use rig config

Based on PR #49 by @kustrun - rebased and extended with additional fixes.

Co-authored-by: kustrun <kustrun@users.noreply.github.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/jack
2026-01-04 14:00:48 -08:00
committed by Steve Yegge
parent 31df1bb2c1
commit eea4435269
14 changed files with 135 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/spf13/cobra"
@@ -10,6 +11,7 @@ import (
"github.com/steveyegge/gastown/internal/events"
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/mail"
"github.com/steveyegge/gastown/internal/rig"
"github.com/steveyegge/gastown/internal/style"
"github.com/steveyegge/gastown/internal/workspace"
)
@@ -147,11 +149,17 @@ func runDone(cmd *cobra.Command, args []string) error {
agentBeadID = getAgentBeadID(ctx)
}
// For COMPLETED, we need an issue ID and branch must not be main
// Get configured default branch for this rig
defaultBranch := "main" // fallback
if rigCfg, err := rig.LoadRigConfig(filepath.Join(townRoot, rigName)); err == nil && rigCfg.DefaultBranch != "" {
defaultBranch = rigCfg.DefaultBranch
}
// For COMPLETED, we need an issue ID and branch must not be the default branch
var mrID string
if exitType == ExitCompleted {
if branch == "main" || branch == "master" {
return fmt.Errorf("cannot submit main/master branch to merge queue")
if branch == defaultBranch || branch == "master" {
return fmt.Errorf("cannot submit %s/master branch to merge queue", defaultBranch)
}
// Check for unpushed commits - branch must be pushed before MR creation
@@ -164,9 +172,6 @@ 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)
}
// Detect the repo's default branch (main vs master)
defaultBranch := g.RemoteDefaultBranch()
// Check that branch has commits ahead of default branch (prevents submitting stale branches)
aheadCount, err := g.CommitsAhead(defaultBranch, branch)
if err != nil {