Support non-main default branches in rig add

- Add DefaultBranch() method to git package to detect repo's default branch
- Store default_branch in rig config.json
- Use detected branch for refinery worktree instead of hardcoding 'main'
- Add LoadRigConfig() to read rig config
- Display correct branch name in rig add output

Fixes wyvern rig creation (uses 'master' not 'main').
This commit is contained in:
Steve Yegge
2025-12-30 19:16:17 -08:00
parent 8c80ad0aff
commit 38bf896296
3 changed files with 55 additions and 13 deletions

View File

@@ -213,6 +213,19 @@ func (g *Git) CurrentBranch() (string, error) {
return g.run("rev-parse", "--abbrev-ref", "HEAD")
}
// DefaultBranch returns the default branch name (what HEAD points to).
// This works for both regular and bare repositories.
// Returns "main" as fallback if detection fails.
func (g *Git) DefaultBranch() string {
// Try symbolic-ref first (works for bare repos)
branch, err := g.run("symbolic-ref", "--short", "HEAD")
if err == nil && branch != "" {
return branch
}
// Fallback to main
return "main"
}
// HasUncommittedChanges returns true if there are uncommitted changes.
func (g *Git) HasUncommittedChanges() (bool, error) {
status, err := g.Status()