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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user