fix(init): ensure sync branch persistence on init
Problem: - Sync branch setup occurred before the config file was initialized - Persistence only targeted the database, leading to loss on re-init Solution: - Reorder initialization to create the config file before sync setup - Synchronize sync branch state to both config file and database Impact: - Settings are preserved across re-initialization and DB clears - Better consistency between file and database state Fixes: #927 (Bug 3)
This commit is contained in:
@@ -287,24 +287,6 @@ With --stealth: configures per-repository git settings for invisible beads usage
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Set sync.branch only if explicitly specified via --branch flag
|
||||
// GH#807: Do NOT auto-detect current branch - if sync.branch is set to main/master,
|
||||
// the worktree created by bd sync will check out main, preventing the user from
|
||||
// checking out main in their working directory (git error: "'main' is already checked out")
|
||||
//
|
||||
// When --branch is not specified, bd sync will commit directly to the current branch
|
||||
// (the original behavior before sync branch feature)
|
||||
if branch != "" {
|
||||
if err := syncbranch.Set(ctx, store, branch); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: failed to set sync branch: %v\n", err)
|
||||
_ = store.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
if !quiet {
|
||||
fmt.Printf(" Sync branch: %s\n", branch)
|
||||
}
|
||||
}
|
||||
|
||||
// === TRACKING METADATA (Pattern B: Warn and Continue) ===
|
||||
// Tracking metadata enhances functionality (diagnostics, version checks, collision detection)
|
||||
// but the system works without it. Failures here degrade gracefully - we warn but continue.
|
||||
@@ -386,6 +368,27 @@ With --stealth: configures per-repository git settings for invisible beads usage
|
||||
}
|
||||
}
|
||||
|
||||
// Set sync.branch only if explicitly specified via --branch flag
|
||||
// GH#807: Do NOT auto-detect current branch - if sync.branch is set to main/master,
|
||||
// the worktree created by bd sync will check out main, preventing the user from
|
||||
// checking out main in their working directory (git error: "'main' is already checked out")
|
||||
//
|
||||
// When --branch is not specified, bd sync will commit directly to the current branch
|
||||
// (the original behavior before sync branch feature)
|
||||
//
|
||||
// GH#927: This must run AFTER createConfigYaml() so that config.yaml exists
|
||||
// and syncbranch.Set() can update it via config.SetYamlConfig() (PR#910 mechanism)
|
||||
if branch != "" {
|
||||
if err := syncbranch.Set(ctx, store, branch); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: failed to set sync branch: %v\n", err)
|
||||
_ = store.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
if !quiet {
|
||||
fmt.Printf(" Sync branch: %s\n", branch)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if git has existing issues to import (fresh clone scenario)
|
||||
// With --from-jsonl: import from local file instead of git history
|
||||
if fromJSONL {
|
||||
|
||||
Reference in New Issue
Block a user