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:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user