fix(done): detect default branch instead of hardcoding 'main' (#42)
Adds RemoteDefaultBranch() to git.go that detects the repo's actual default branch by checking origin/HEAD, then falling back to checking for origin/master or origin/main. Updates done.go to use this detection instead of hardcoded "main": - Line 168: CommitsAhead now uses detected default branch - Line 173: Error message uses detected branch name - Line 187: Target branch defaults to detected branch Fixes repos using 'master' as default branch (pre-2020 repos). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
This commit is contained in:
@@ -164,13 +164,16 @@ 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)
|
||||
// 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 {
|
||||
return fmt.Errorf("checking commits ahead of main: %w", err)
|
||||
return fmt.Errorf("checking commits ahead of %s: %w", defaultBranch, err)
|
||||
}
|
||||
if aheadCount == 0 {
|
||||
return fmt.Errorf("branch '%s' has 0 commits ahead of main; nothing to merge", branch)
|
||||
return fmt.Errorf("branch '%s' has 0 commits ahead of %s; nothing to merge", branch, defaultBranch)
|
||||
}
|
||||
|
||||
if issueID == "" {
|
||||
@@ -181,7 +184,7 @@ func runDone(cmd *cobra.Command, args []string) error {
|
||||
bd := beads.New(cwd)
|
||||
|
||||
// Determine target branch (auto-detect integration branch if applicable)
|
||||
target := "main"
|
||||
target := defaultBranch
|
||||
autoTarget, err := detectIntegrationBranch(bd, g, issueID)
|
||||
if err == nil && autoTarget != "" {
|
||||
target = autoTarget
|
||||
|
||||
Reference in New Issue
Block a user