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

@@ -1105,3 +1105,50 @@ func TestHashBasedStalenessDetection_bd_f2f(t *testing.T) {
t.Error("hasJSONLChanged should return false after hash is updated to match JSONL")
}
}
// TestResolveNoGitHistoryForFromMain tests that --from-main forces noGitHistory=true
// to prevent creating incorrect deletion records for locally-created beads.
// See: https://github.com/steveyegge/beads/issues/417
func TestResolveNoGitHistoryForFromMain(t *testing.T) {
tests := []struct {
name string
fromMain bool
noGitHistory bool
want bool
}{
{
name: "fromMain=true forces noGitHistory=true regardless of flag",
fromMain: true,
noGitHistory: false,
want: true,
},
{
name: "fromMain=true with noGitHistory=true stays true",
fromMain: true,
noGitHistory: true,
want: true,
},
{
name: "fromMain=false preserves noGitHistory=false",
fromMain: false,
noGitHistory: false,
want: false,
},
{
name: "fromMain=false preserves noGitHistory=true",
fromMain: false,
noGitHistory: true,
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := resolveNoGitHistoryForFromMain(tt.fromMain, tt.noGitHistory)
if got != tt.want {
t.Errorf("resolveNoGitHistoryForFromMain(%v, %v) = %v, want %v",
tt.fromMain, tt.noGitHistory, got, tt.want)
}
})
}
}