catch case when hook path is default

This commit is contained in:
Maidul Islam
2023-05-23 19:34:31 -04:00
parent 952cf47b9a
commit f2de1778cb
+5 -1
View File
@@ -526,7 +526,11 @@ func GetGitRoot() (string, error) {
func getHooksPath() (string, error) { func getHooksPath() (string, error) {
out, err := exec.Command("git", "config", "core.hooksPath").Output() out, err := exec.Command("git", "config", "core.hooksPath").Output()
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get Git hooks path: %s", err) if len(out) == 0 {
out = []byte(".git/hooks") // set the default hook
} else {
log.Error().Msgf("Failed to get Git hooks path: %s\nOutput: %s\n", err, out)
}
} }
hooksPath := strings.TrimSpace(string(out)) hooksPath := strings.TrimSpace(string(out))