fix(doctor): skip JSONL tracking checks in sync-branch mode (GH#858) (#860)

When sync-branch is configured, JSONL files are intentionally untracked
in working branches and only committed to the dedicated sync branch.
The CheckIssuesTracking and CheckUntrackedBeadsFiles checks now detect
sync-branch mode via GetFromYAML() and return OK status instead of
false warnings.
This commit is contained in:
Peter Chanthamynavong
2026-01-02 15:56:33 -08:00
committed by GitHub
parent 73ed489c9e
commit 5619dc0798
2 changed files with 29 additions and 1 deletions

View File

@@ -6,6 +6,8 @@ import (
"os/exec"
"path/filepath"
"strings"
"github.com/steveyegge/beads/internal/syncbranch"
)
// GitignoreTemplate is the canonical .beads/.gitignore content
@@ -133,6 +135,7 @@ func FixGitignore() error {
// CheckIssuesTracking verifies that issues.jsonl is tracked by git.
// This catches cases where global gitignore patterns (e.g., *.jsonl) would
// cause issues.jsonl to be ignored, breaking bd sync.
// In sync-branch mode, the file may be intentionally ignored in working branches (GH#858).
func CheckIssuesTracking() DoctorCheck {
issuesPath := filepath.Join(".beads", "issues.jsonl")
@@ -146,6 +149,17 @@ func CheckIssuesTracking() DoctorCheck {
}
}
// In sync-branch mode, JSONL files may be intentionally ignored in working branches.
// They are tracked only in the dedicated sync branch.
if branch := syncbranch.GetFromYAML(); branch != "" {
return DoctorCheck{
Name: "Issues Tracking",
Status: StatusOK,
Message: "N/A (sync-branch mode)",
Detail: fmt.Sprintf("JSONL files tracked in '%s' branch only", branch),
}
}
// Check if git considers this file ignored
// git check-ignore exits 0 if ignored, 1 if not ignored, 128 if error
cmd := exec.Command("git", "check-ignore", "-q", issuesPath) // #nosec G204 - args are hardcoded paths

View File

@@ -13,6 +13,7 @@ import (
"github.com/steveyegge/beads/cmd/bd/doctor/fix"
"github.com/steveyegge/beads/internal/beads"
"github.com/steveyegge/beads/internal/git"
"github.com/steveyegge/beads/internal/syncbranch"
)
// CheckInstallation verifies that .beads directory exists
@@ -142,7 +143,9 @@ func CheckPermissions(path string) DoctorCheck {
}
}
// CheckUntrackedBeadsFiles checks for untracked .beads/*.jsonl files that should be committed
// CheckUntrackedBeadsFiles checks for untracked .beads/*.jsonl files that should be committed.
// In sync-branch mode, JSONL files are intentionally untracked in working branches
// and only committed to the dedicated sync branch (GH#858).
func CheckUntrackedBeadsFiles(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads")
@@ -155,6 +158,17 @@ func CheckUntrackedBeadsFiles(path string) DoctorCheck {
}
}
// In sync-branch mode, JSONL files are intentionally untracked in working branches.
// They are committed only to the dedicated sync branch via bd sync.
if branch := syncbranch.GetFromYAML(); branch != "" {
return DoctorCheck{
Name: "Untracked Files",
Status: StatusOK,
Message: "N/A (sync-branch mode)",
Detail: fmt.Sprintf("JSONL files tracked in '%s' branch only", branch),
}
}
// Check if we're in a git repository using worktree-aware detection
_, err := git.GetGitDir()
if err != nil {