fix: bd doctor falsely reports pre-push hook is not a bd hook (#799)
The CheckSyncBranchHookCompatibility was checking core.hooksPath first, while CheckGitHooks always uses .git/hooks/. This caused inconsistent results when core.hooksPath was set globally. Fix: Remove core.hooksPath check from CheckSyncBranchHookCompatibility to match CheckGitHooks behavior. Both now consistently use .git/hooks/. Note: A future improvement could make both respect core.hooksPath.
This commit is contained in:
@@ -276,22 +276,9 @@ func CheckSyncBranchHookCompatibility(path string) DoctorCheck {
|
||||
gitDir = filepath.Join(path, gitDir)
|
||||
}
|
||||
|
||||
// Check for pre-push hook in standard location or shared hooks location
|
||||
var hookPath string
|
||||
|
||||
// First check if core.hooksPath is configured (shared hooks)
|
||||
hooksPathCmd := exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
hooksPathCmd.Dir = path
|
||||
if hooksPathOutput, err := hooksPathCmd.Output(); err == nil {
|
||||
sharedHooksDir := strings.TrimSpace(string(hooksPathOutput))
|
||||
if !filepath.IsAbs(sharedHooksDir) {
|
||||
sharedHooksDir = filepath.Join(path, sharedHooksDir)
|
||||
}
|
||||
hookPath = filepath.Join(sharedHooksDir, "pre-push")
|
||||
} else {
|
||||
// Use standard .git/hooks location
|
||||
hookPath = filepath.Join(gitDir, "hooks", "pre-push")
|
||||
}
|
||||
// Use standard .git/hooks location for consistency with CheckGitHooks (issue #799)
|
||||
// Note: core.hooksPath is intentionally NOT checked here to match CheckGitHooks behavior.
|
||||
hookPath := filepath.Join(gitDir, "hooks", "pre-push")
|
||||
|
||||
hookContent, err := os.ReadFile(hookPath) // #nosec G304 - path is controlled
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user