fix: bd sync now only commits .beads/ files, not other staged files (bd-red)

Previously, bd sync would commit ALL staged files when committing beads
changes. This could lead to unintended commits of work-in-progress code
that users had staged but weren't ready to commit.

Changed gitCommitBeadsDir to use pathspec (-- .beads/) to explicitly
limit the commit to only .beads/ files.

Also added in previous commit (bd-pbj):
- New Untracked Files check in bd doctor for untracked .beads/*.jsonl
- bd doctor --fix can now stage and commit untracked JSONL files

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-26 20:46:47 -08:00
parent 3a343ead8d
commit ab330ea39d
2 changed files with 7 additions and 4 deletions

View File

@@ -554,7 +554,8 @@ func gitCommit(ctx context.Context, filePath string, message string) error {
return nil
}
// gitCommitBeadsDir stages and commits all tracked files in .beads/
// gitCommitBeadsDir stages and commits only files in .beads/ (bd-red fix)
// This ensures bd sync doesn't accidentally commit other staged files.
func gitCommitBeadsDir(ctx context.Context, message string) error {
beadsDir := findBeadsDir()
if beadsDir == "" {
@@ -572,8 +573,10 @@ func gitCommitBeadsDir(ctx context.Context, message string) error {
message = fmt.Sprintf("bd sync: %s", time.Now().Format("2006-01-02 15:04:05"))
}
// Commit
commitCmd := exec.CommandContext(ctx, "git", "commit", "-m", message)
// Commit only .beads/ files using -- pathspec (bd-red)
// This prevents accidentally committing other staged files that the user
// may have staged but wasn't ready to commit yet.
commitCmd := exec.CommandContext(ctx, "git", "commit", "-m", message, "--", beadsDir)
output, err := commitCmd.CombinedOutput()
if err != nil {
return fmt.Errorf("git commit failed: %w\n%s", err, output)