fix: Auto-configure sync.branch during bd init (bd-flil)
- bd init now auto-sets sync.branch to current git branch - Fixes 'bd sync --status' error after fresh bd init - Changed all branch detection to use 'git symbolic-ref' instead of 'git rev-parse' to work in fresh repos without commits - Updated init.go, init_team.go, sync.go, version.go 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -470,7 +470,8 @@ func gitPull(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Get current branch name
|
||||
branchCmd := exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
// Use symbolic-ref to work in fresh repos without commits (bd-flil)
|
||||
branchCmd := exec.CommandContext(ctx, "git", "symbolic-ref", "--short", "HEAD")
|
||||
branchOutput, err := branchCmd.Output()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get current branch: %w", err)
|
||||
@@ -678,8 +679,9 @@ func exportToJSONL(ctx context.Context, jsonlPath string) error {
|
||||
}
|
||||
|
||||
// getCurrentBranch returns the name of the current git branch
|
||||
// Uses symbolic-ref instead of rev-parse to work in fresh repos without commits (bd-flil)
|
||||
func getCurrentBranch(ctx context.Context) (string, error) {
|
||||
cmd := exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
cmd := exec.CommandContext(ctx, "git", "symbolic-ref", "--short", "HEAD")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get current branch: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user