fix(sync): protect local issues from git-history-backfill during sync (#485)
Fix sync bug where newly created issues were incorrectly tombstoned during bd sync. The root cause was git-history-backfill finding issues in local commits on the sync branch, then tombstoning them when they weren't in the merged JSONL. The fix protects issues from the left snapshot (local export) from git-history-backfill. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
@@ -520,8 +520,10 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
}
|
||||
|
||||
// Step 4: Import updated JSONL after pull
|
||||
// Enable --protect-left-snapshot to prevent git-history-backfill from
|
||||
// tombstoning issues that were in our local export but got lost during merge (bd-sync-deletion fix)
|
||||
fmt.Println("→ Importing updated JSONL...")
|
||||
if err := importFromJSONL(ctx, jsonlPath, renameOnImport, noGitHistory); err != nil {
|
||||
if err := importFromJSONL(ctx, jsonlPath, renameOnImport, noGitHistory, true); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error importing: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -1455,23 +1457,37 @@ func mergeSyncBranch(ctx context.Context, dryRun bool) error {
|
||||
}
|
||||
|
||||
// importFromJSONL imports the JSONL file by running the import command
|
||||
func importFromJSONL(ctx context.Context, jsonlPath string, renameOnImport bool, noGitHistory ...bool) error {
|
||||
// Optional parameters: noGitHistory, protectLeftSnapshot (bd-sync-deletion fix)
|
||||
func importFromJSONL(ctx context.Context, jsonlPath string, renameOnImport bool, opts ...bool) error {
|
||||
// Get current executable path to avoid "./bd" path issues
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot resolve current executable: %w", err)
|
||||
}
|
||||
|
||||
// Parse optional parameters
|
||||
noGitHistory := false
|
||||
protectLeftSnapshot := false
|
||||
if len(opts) > 0 {
|
||||
noGitHistory = opts[0]
|
||||
}
|
||||
if len(opts) > 1 {
|
||||
protectLeftSnapshot = opts[1]
|
||||
}
|
||||
|
||||
// Build args for import command
|
||||
// Use --no-daemon to ensure subprocess uses direct mode, avoiding daemon connection issues
|
||||
args := []string{"--no-daemon", "import", "-i", jsonlPath}
|
||||
if renameOnImport {
|
||||
args = append(args, "--rename-on-import")
|
||||
}
|
||||
// Handle optional noGitHistory parameter
|
||||
if len(noGitHistory) > 0 && noGitHistory[0] {
|
||||
if noGitHistory {
|
||||
args = append(args, "--no-git-history")
|
||||
}
|
||||
// Add --protect-left-snapshot flag for post-pull imports (bd-sync-deletion fix)
|
||||
if protectLeftSnapshot {
|
||||
args = append(args, "--protect-left-snapshot")
|
||||
}
|
||||
|
||||
// Run import command
|
||||
cmd := exec.CommandContext(ctx, exe, args...) // #nosec G204 - bd import command from trusted binary
|
||||
|
||||
Reference in New Issue
Block a user