fix: validate project files in FindBeadsDir (bd-420) (#424)
FindBeadsDir() now checks for actual beads project files before returning a .beads directory. This prevents false positives when ~/.beads/ exists only for daemon registry (registry.json). Changes: - Add hasBeadsProjectFiles() helper that checks for: - metadata.json or config.yaml (project config) - *.db files (excluding backups and vc.db) - *.jsonl files (JSONL-only mode) - Update FindBeadsDir() to validate directories during tree search - Add comprehensive tests for project file detection - Update version_tracking_test.go to create project files Fixes #420 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -124,12 +124,18 @@ func TestTrackBdVersion_NoBeadsDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTrackBdVersion_FirstRun(t *testing.T) {
|
||||
// Create temp .beads directory
|
||||
// Create temp .beads directory with a project file (bd-420)
|
||||
// FindBeadsDir now requires actual project files, not just directory existence
|
||||
tmpDir := t.TempDir()
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
t.Fatalf("Failed to create .beads: %v", err)
|
||||
}
|
||||
// Create a database file so FindBeadsDir finds this directory
|
||||
dbPath := filepath.Join(beadsDir, "beads.db")
|
||||
if err := os.WriteFile(dbPath, []byte{}, 0644); err != nil {
|
||||
t.Fatalf("Failed to create db file: %v", err)
|
||||
}
|
||||
|
||||
// Change to temp directory
|
||||
origWd, _ := os.Getwd()
|
||||
|
||||
Reference in New Issue
Block a user