bd-c8x: Stop searching parent directories at git root
Directory discovery (FindBeadsDir, findDatabaseInTree, FindAllDatabases) now stops at the git repository root to avoid finding unrelated databases in parent directories (e.g., ~/.beads). Added findGitRoot() helper that uses 'git rev-parse --show-toplevel'. Also updated TestCheckDatabaseVersionJSONLMode to properly simulate no-db mode by creating config.yaml with 'no-db: true'. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -383,6 +383,13 @@ func TestCheckDatabaseVersionJSONLMode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Create config.yaml with no-db: true to indicate intentional JSONL-only mode
|
||||
// Without this, doctor treats it as a fresh clone needing 'bd init' (bd-4ew)
|
||||
configPath := filepath.Join(beadsDir, "config.yaml")
|
||||
if err := os.WriteFile(configPath, []byte("no-db: true\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
check := checkDatabaseVersion(tmpDir)
|
||||
|
||||
if check.Status != statusOK {
|
||||
@@ -396,6 +403,34 @@ func TestCheckDatabaseVersionJSONLMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckDatabaseVersionFreshClone(t *testing.T) {
|
||||
// Create temporary directory with .beads and JSONL but no database
|
||||
// This simulates a fresh clone that needs 'bd init'
|
||||
tmpDir := t.TempDir()
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
if err := os.Mkdir(beadsDir, 0750); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Create issues.jsonl with an issue (no config.yaml = not no-db mode)
|
||||
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
|
||||
if err := os.WriteFile(jsonlPath, []byte(`{"id":"test-1","title":"Test"}`+"\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
check := checkDatabaseVersion(tmpDir)
|
||||
|
||||
if check.Status != statusWarning {
|
||||
t.Errorf("Expected warning status for fresh clone, got %s", check.Status)
|
||||
}
|
||||
if check.Message != "Fresh clone detected (no database)" {
|
||||
t.Errorf("Expected fresh clone message, got %s", check.Message)
|
||||
}
|
||||
if check.Fix == "" {
|
||||
t.Error("Expected fix field to recommend 'bd init'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
|
||||
Reference in New Issue
Block a user