fix: resolve symlink paths in autoimport.go for macOS
Both findBeadsDir() and findGitRoot() now use filepath.EvalSymlinks() to resolve to canonical paths before comparison. This fixes the issue where filepath.Rel() fails on macOS because /var is a symlink to /private/var, causing path mismatches. Fixes: TestDatabaseReinitialization failures on macOS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -184,7 +184,12 @@ func findBeadsDir() string {
|
||||
for {
|
||||
beadsDir := filepath.Join(dir, ".beads")
|
||||
if info, err := os.Stat(beadsDir); err == nil && info.IsDir() {
|
||||
return beadsDir
|
||||
// Resolve symlinks to get canonical path (fixes macOS /var -> /private/var)
|
||||
resolved, err := filepath.EvalSymlinks(beadsDir)
|
||||
if err != nil {
|
||||
return beadsDir // Fall back to unresolved if EvalSymlinks fails
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
|
||||
parent := filepath.Dir(dir)
|
||||
@@ -206,7 +211,7 @@ func findGitRoot() string {
|
||||
return ""
|
||||
}
|
||||
root := string(bytes.TrimSpace(output))
|
||||
|
||||
|
||||
// Normalize path for the current OS
|
||||
// Git on Windows may return paths with forward slashes (C:/Users/...)
|
||||
// or Unix-style paths (/c/Users/...), convert to native format
|
||||
@@ -219,7 +224,13 @@ func findGitRoot() string {
|
||||
root = filepath.FromSlash(root)
|
||||
}
|
||||
}
|
||||
return root
|
||||
|
||||
// Resolve symlinks to get canonical path (fixes macOS /var -> /private/var)
|
||||
resolved, err := filepath.EvalSymlinks(root)
|
||||
if err != nil {
|
||||
return root // Fall back to unresolved if EvalSymlinks fails
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
|
||||
// importFromGit imports issues from git at the specified ref (bd-0is: supports sync-branch)
|
||||
|
||||
Reference in New Issue
Block a user