fix: bypass gitHasBeadsChanges when using sync-branch (#812)

When using sync-branch with aggressive gitignore on code branches
(.beads/* ignored), gitHasBeadsChanges() returns false because git
does not track the files. This caused bd sync to skip CommitToSyncBranch
entirely, even though CommitToSyncBranch has its own internal change
detection that checks the worktree where gitignore is different.

The fix bypasses gitHasBeadsChanges when useSyncBranch is true, letting
CommitToSyncBranch determine if there are actual changes in the worktree.

Closes #812

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 18:04:15 -08:00
parent 38a6097512
commit cf4aff1cb4
2 changed files with 118 additions and 3 deletions

View File

@@ -475,9 +475,21 @@ Use --merge to merge the sync branch back to main branch.`,
}
// Step 2: Check if there are changes to commit (check entire .beads/ directory)
hasChanges, err := gitHasBeadsChanges(ctx)
if err != nil {
FatalError("checking git status: %v", err)
// GH#812: When using sync-branch, skip this check - CommitToSyncBranch handles it internally.
// The main repo's .beads may be gitignored on code branches (valid per #797/#801).
// In that case, gitHasBeadsChanges returns false even when JSONL has changes,
// because git doesn't track the files. CommitToSyncBranch copies files to the
// worktree where they ARE tracked (different gitignore) and checks there.
var hasChanges bool
var err error
if !useSyncBranch {
hasChanges, err = gitHasBeadsChanges(ctx)
if err != nil {
FatalError("checking git status: %v", err)
}
} else {
// Let CommitToSyncBranch determine if there are actual changes in the worktree
hasChanges = true
}
// Track if we already pushed via worktree (to skip Step 5)