Skip to content

Commit 9f3603b

Browse files
osamu2001steveyegge
authored andcommitted
fix(doctor): honor bare-parent fallback in dolt lock checks (beads-9f74-f5e)
1 parent 94a5524 commit 9f3603b

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

cmd/bd/doctor/bare_parent_fallback_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ func TestCheckLockHealth_BareParentWorktreeFallback(t *testing.T) {
5555
}
5656
}
5757

58+
func TestCheckDoltLocks_BareParentWorktreeFallback(t *testing.T) {
59+
bareDir, featureWorktreeDir := setupBareParentWorktreeForDoctorTest(t)
60+
bareBeadsDir := filepath.Join(bareDir, ".beads")
61+
if err := os.MkdirAll(bareBeadsDir, 0o750); err != nil {
62+
t.Fatal(err)
63+
}
64+
if err := os.WriteFile(filepath.Join(bareBeadsDir, "metadata.json"), []byte(`{"backend":"dolt"}`), 0o600); err != nil {
65+
t.Fatal(err)
66+
}
67+
68+
t.Setenv("BEADS_DOLT_SERVER_PORT", "59999")
69+
check := CheckDoltLocks(featureWorktreeDir)
70+
if check.Message == "N/A (not Dolt backend)" {
71+
t.Fatalf("expected fallback to parent beads dir, got %s", check.Message)
72+
}
73+
}
74+
5875
func setupBareParentWorktreeForDoctorTest(t *testing.T) (string, string) {
5976
t.Helper()
6077

cmd/bd/doctor/migration_validation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func CheckMigrationReadiness(path string) (DoctorCheck, MigrationValidationResul
5454
SchemaValid: true,
5555
}
5656

57-
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
57+
beadsDir := ResolveBeadsDirForRepo(path)
5858

5959
// Check if .beads exists
6060
if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
@@ -166,7 +166,7 @@ func CheckMigrationCompletion(path string) (DoctorCheck, MigrationValidationResu
166166
SchemaValid: true,
167167
}
168168

169-
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
169+
beadsDir := ResolveBeadsDirForRepo(path)
170170

171171
// Check if .beads exists
172172
if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
@@ -324,7 +324,7 @@ func CheckMigrationCompletion(path string) (DoctorCheck, MigrationValidationResu
324324

325325
// CheckDoltLocks checks if the Dolt database has any locks or uncommitted changes.
326326
func CheckDoltLocks(path string) DoctorCheck {
327-
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
327+
beadsDir := ResolveBeadsDirForRepo(path)
328328

329329
// Only run for Dolt backend
330330
if !IsDoltBackend(beadsDir) {

0 commit comments

Comments
 (0)