# Conflicts:
#	.beads/beads.jsonl
This commit is contained in:
Steve Yegge
2025-11-23 19:48:05 -08:00
6 changed files with 19 additions and 10 deletions

View File

@@ -210,7 +210,16 @@ With --no-db: creates .beads/ directory and issues.jsonl file instead of SQLite
os.Exit(1) os.Exit(1)
} }
// Set sync.branch if specified // Set sync.branch: use explicit --branch flag, or auto-detect current branch
// This ensures bd sync --status works after bd init (bd-flil)
if branch == "" && isGitRepo() {
// Auto-detect current branch if not specified
currentBranch, err := getGitBranch()
if err == nil && currentBranch != "" {
branch = currentBranch
}
}
if branch != "" { if branch != "" {
if err := syncbranch.Set(ctx, store, branch); err != nil { if err := syncbranch.Set(ctx, store, branch); err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to set sync branch: %v\n", err) fmt.Fprintf(os.Stderr, "Error: failed to set sync branch: %v\n", err)

View File

@@ -188,13 +188,14 @@ func runTeamWizard(ctx context.Context, store storage.Storage) error {
} }
// getGitBranch returns the current git branch name // getGitBranch returns the current git branch name
// Uses symbolic-ref instead of rev-parse to work in fresh repos without commits (bd-flil)
func getGitBranch() (string, error) { func getGitBranch() (string, error) {
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD") cmd := exec.Command("git", "symbolic-ref", "--short", "HEAD")
output, err := cmd.Output() output, err := cmd.Output()
if err != nil { if err != nil {
return "", err return "", err
} }
return strings.TrimSpace(string(output)), nil return strings.TrimSpace(string(output)), nil
} }

View File

@@ -470,7 +470,8 @@ func gitPull(ctx context.Context) error {
} }
// Get current branch name // 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() branchOutput, err := branchCmd.Output()
if err != nil { if err != nil {
return fmt.Errorf("failed to get current branch: %w", err) 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 // 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) { 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() output, err := cmd.Output()
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get current branch: %w", err) return "", fmt.Errorf("failed to get current branch: %w", err)

View File

@@ -151,7 +151,8 @@ func resolveBranch() string {
} }
// Fallback: try to get branch from git at runtime // Fallback: try to get branch from git at runtime
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD") // Use symbolic-ref to work in fresh repos without commits (bd-flil)
cmd := exec.Command("git", "symbolic-ref", "--short", "HEAD")
cmd.Dir = "." cmd.Dir = "."
if output, err := cmd.Output(); err == nil { if output, err := cmd.Output(); err == nil {
if branch := strings.TrimSpace(string(output)); branch != "" && branch != "HEAD" { if branch := strings.TrimSpace(string(output)); branch != "" && branch != "HEAD" {

View File

@@ -92,14 +92,11 @@ func getCachedOrGenerateDB(b *testing.B, cacheKey string, generateFn func(contex
ctx := context.Background() ctx := context.Background()
store, err := New(ctx, dbPath) store, err := New(ctx, dbPath)
if err != nil { if err != nil {
b.Fatalf("Failed to create storage: %v", err) b.Fatalf("Failed to create storage: %v", err)
} }
ctx := context.Background()
// Initialize database with prefix // Initialize database with prefix
if err := store.SetConfig(ctx, "issue_prefix", "bd-"); err != nil { if err := store.SetConfig(ctx, "issue_prefix", "bd-"); err != nil {
store.Close() store.Close()

View File

@@ -127,7 +127,6 @@ func setupBenchDB(tb testing.TB) (*SQLiteStorage, func()) {
tb.Fatalf("Failed to create storage: %v", err) tb.Fatalf("Failed to create storage: %v", err)
} }
ctx := context.Background()
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil { if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
tb.Fatalf("Failed to set issue_prefix: %v", err) tb.Fatalf("Failed to set issue_prefix: %v", err)
} }