From 6273e5531a8248cd9fcbdb4250436e57d8e8b3c7 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Fri, 17 Dec 2021 11:48:32 +0100 Subject: [PATCH] Fix doc and syntax --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0fbbb3b..37efac2 100644 --- a/main.go +++ b/main.go @@ -34,10 +34,10 @@ func detectGitVersion() (string, error) { return defaulVersion, errors.New("git executable not found") } - // exec git log -n1 --pretty=format:"%h" + // get the latest commit hash if out, err := exec.Command("git", "log", "-n1", "--pretty=format:%h").Output(); err == nil { latestCommit := strings.TrimSpace(string(out)) - // then exec git branch --show-current + // then get the current branch/tag out, err := exec.Command("git", "branch", "--show-current").Output() if err != nil { return defaulVersion, errors.New("git branch --show-current failed") @@ -49,7 +49,6 @@ func detectGitVersion() (string, error) { if err == nil { return strings.TrimSpace(string(out)), nil } else { - return currentBranch + "-" + latestCommit, nil } }