From 3385b61272d33a9eeea529a1b05d1d018612f519 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Fri, 17 Dec 2021 11:40:56 +0100 Subject: [PATCH] Check if .git is a directory --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5fd61b3..dbd7d71 100644 --- a/main.go +++ b/main.go @@ -20,8 +20,12 @@ var ChartsDir = "chart" func detectGitVersion() (string, error) { // Check if .git directory exists - if _, err := os.Stat(".git"); err != nil { - return "0.0.1", errors.New("No git repository found") + if s, err := os.Stat(".git"); err != nil { + // .git should be a directory + if !s.IsDir() { + return "", errors.New(".git is not a directory") + } + return "0.0.1", errors.New("no git repository found") } // check if "git" executable is callable