fix(sync): default noGitHistory=true for --from-main mode (#418)

Fixes #417: When using --from-main mode (either explicitly or auto-detected),
git history backfill now defaults to disabled. This prevents creating
incorrect deletion records for locally-created beads that don't exist in
main's git history.

Changes:
- Add resolveNoGitHistoryForFromMain() helper function
- Apply noGitHistory=true for both explicit and auto-detected from-main mode
- Add comprehensive unit tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: GraemeF <graeme@graemef.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-29 22:29:10 -08:00
parent d5f2d91d04
commit 3ffd1c1030
2 changed files with 63 additions and 1 deletions

View File

@@ -68,6 +68,9 @@ Use --merge to merge the sync branch back to main branch.`,
daemonClient = nil
}
// Resolve noGitHistory based on fromMain (fixes #417)
noGitHistory = resolveNoGitHistoryForFromMain(fromMain, noGitHistory)
// Find JSONL path
jsonlPath := findJSONLPath()
if jsonlPath == "" {
@@ -170,7 +173,8 @@ Use --merge to merge the sync branch back to main branch.`,
if hasGitRemote(ctx) {
// Remote exists but no upstream - use from-main mode
fmt.Println("→ No upstream configured, using --from-main mode")
if err := doSyncFromMain(ctx, jsonlPath, renameOnImport, dryRun, noGitHistory); err != nil {
// Force noGitHistory=true for auto-detected from-main mode (fixes #417)
if err := doSyncFromMain(ctx, jsonlPath, renameOnImport, dryRun, true); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
@@ -1495,3 +1499,14 @@ func sanitizeJSONLWithDeletions(jsonlPath string) (*SanitizeResult, error) {
return result, nil
}
// resolveNoGitHistoryForFromMain returns the resolved noGitHistory value for sync operations.
// When syncing from main (--from-main), noGitHistory is forced to true to prevent creating
// incorrect deletion records for locally-created beads that don't exist on main.
// See: https://github.com/steveyegge/beads/issues/417
func resolveNoGitHistoryForFromMain(fromMain, noGitHistory bool) bool {
if fromMain {
return true
}
return noGitHistory
}