We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f891fd9 commit f3478f2Copy full SHA for f3478f2
internal/build/env.go
@@ -20,6 +20,7 @@ import (
20
"flag"
21
"fmt"
22
"os"
23
+ "regexp"
24
"strconv"
25
"strings"
26
"time"
@@ -99,6 +100,13 @@ func LocalEnv() Environment {
99
100
if fields := strings.Fields(head); len(fields) == 2 {
101
head = fields[1]
102
} else {
103
+ // In this case we are in "detached head" state
104
+ // see: https://git-scm.com/docs/git-checkout#_detached_head
105
+ // Additional check required to verify, that file contains commit hash
106
+ commitRe, _ := regexp.Compile("^([0-9a-f]{40})$")
107
+ if commit := commitRe.FindString(head); commit != "" && env.Commit == "" {
108
+ env.Commit = commit
109
+ }
110
return env
111
}
112
if env.Commit == "" {
0 commit comments