refactor: consolidate duplicate path-finding utilities (bd-74w1, bd-4nqq)

- Add git.GetRepoRoot() with Windows path normalization
- Update beads.findGitRoot() to delegate to git.GetRepoRoot()
- Replace findBeadsDir() with beads.FindBeadsDir() across 8 files
- Remove duplicate findBeadsDir() and findGitRoot() function definitions
- Remove dead test code (TestInfoCommand, TestInfoWithNoDaemon)
- Update tests to work with consolidated APIs

Part of Code Health Review Dec 2025 epic (bd-tggf).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-22 21:15:41 -08:00
parent ca1927bfaa
commit fc0b98730a
10 changed files with 77 additions and 107 deletions

View File

@@ -11,7 +11,6 @@ import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
@@ -442,15 +441,10 @@ type DatabaseInfo struct {
// or empty string if not in a git repository. Used to limit directory
// tree walking to within the current git repo (bd-c8x).
//
// This function is worktree-aware and will correctly identify the repository
// root in both regular repositories and git worktrees.
// This function delegates to git.GetRepoRoot() which is worktree-aware
// and handles Windows path normalization.
func findGitRoot() string {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
output, err := cmd.Output()
if err != nil {
return ""
}
return strings.TrimSpace(string(output))
return git.GetRepoRoot()
}
// findDatabaseInTree walks up the directory tree looking for .beads/*.db