Fix bd-hv01: Implement deletion tracking for multi-workspace sync
- Add 3-way merge deletion tracking using snapshot files - Create .beads/beads.base.jsonl and .beads/beads.left.jsonl snapshots - Integrate into both sync.go and daemon_sync.go - Add comprehensive test suite in deletion_tracking_test.go - Update .gitignore to exclude snapshot files This fixes the resurrection bug where deleted issues come back after multi-workspace git sync. Uses the beads-merge 3-way merge logic to detect and apply deletions correctly.
This commit is contained in:
@@ -148,6 +148,11 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
fmt.Fprintf(os.Stderr, "Error exporting: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Capture left snapshot (pre-pull state) for 3-way merge
|
||||
if err := captureLeftSnapshot(jsonlPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to capture snapshot for deletion tracking: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Check if there are changes to commit
|
||||
@@ -192,6 +197,14 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3.5: Perform 3-way merge and prune deletions
|
||||
if err := ensureStoreActive(); err == nil && store != nil {
|
||||
if err := applyDeletionsFromMerge(ctx, store, jsonlPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error during 3-way merge: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Import updated JSONL after pull
|
||||
fmt.Println("→ Importing updated JSONL...")
|
||||
if err := importFromJSONL(ctx, jsonlPath, renameOnImport); err != nil {
|
||||
@@ -249,6 +262,11 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
fmt.Println("→ DB and JSONL in sync, skipping re-export")
|
||||
}
|
||||
}
|
||||
|
||||
// Update base snapshot after successful import
|
||||
if err := updateBaseSnapshot(jsonlPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to update base snapshot: %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user