From f2de1778cb8e71ab58d45588d6b47a09c22d52fe Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 23 May 2023 19:34:31 -0400 Subject: [PATCH] catch case when hook path is default --- cli/packages/cmd/scan.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/packages/cmd/scan.go b/cli/packages/cmd/scan.go index cc8cd2e69..1226e3319 100644 --- a/cli/packages/cmd/scan.go +++ b/cli/packages/cmd/scan.go @@ -526,7 +526,11 @@ func GetGitRoot() (string, error) { func getHooksPath() (string, error) { out, err := exec.Command("git", "config", "core.hooksPath").Output() 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))