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

@@ -87,12 +87,16 @@ type Engineer struct {
// NewEngineer creates a new Engineer for the given rig.
func NewEngineer(r *rig.Rig) *Engineer {
cfg := DefaultMergeQueueConfig()
// Override target branch with rig's configured default branch
cfg.TargetBranch = r.DefaultBranch()
return &Engineer{
rig: r,
beads: beads.New(r.Path),
mrQueue: mrqueue.New(r.Path),
git: git.NewGit(r.Path),
config: DefaultMergeQueueConfig(),
config: cfg,
workDir: r.Path,
output: os.Stdout,
eventLogger: mrqueue.NewEventLoggerFromRig(r.Path),

View File

@@ -359,6 +359,9 @@ func (m *Manager) issueToMR(issue *beads.Issue) *MergeRequest {
return nil
}
// Get configured default branch for this rig
defaultBranch := m.rig.DefaultBranch()
fields := beads.ParseMRFields(issue)
if fields == nil {
// No MR fields in description, construct from title/ID
@@ -367,14 +370,14 @@ func (m *Manager) issueToMR(issue *beads.Issue) *MergeRequest {
IssueID: issue.ID,
Status: MROpen,
CreatedAt: parseTime(issue.CreatedAt),
TargetBranch: "main",
TargetBranch: defaultBranch,
}
}
// Default target to main if not specified
// Default target to rig's default branch if not specified
target := fields.Target
if target == "" {
target = "main"
target = defaultBranch
}
return &MergeRequest{