version: construct short hash in dev mode if GitCommit is given.

Allows a dev built to provide GitCommit and have the short hash
computed correctly, even if the Go embedded build info lacks a
git commit.

Signed-off-by: David Anderson <dave@natulte.net>
pull/6846/head
David Anderson 1 year ago committed by Dave Anderson
parent 2a1f1c79ca
commit eb682d2a0b

@ -41,14 +41,11 @@ func init() {
return
}
var dirty string // "-dirty" suffix if dirty
var commitHashAbbrev, commitDate string
var commitDate string
for _, s := range bi.Settings {
switch s.Key {
case "vcs.revision":
GitCommit = s.Value
if len(s.Value) >= 9 {
commitHashAbbrev = s.Value[:9]
}
case "vcs.time":
if len(s.Value) >= len("yyyy-mm-dd") {
commitDate = s.Value[:len("yyyy-mm-dd")]
@ -61,6 +58,10 @@ func init() {
}
}
}
commitHashAbbrev := GitCommit
if len(commitHashAbbrev) >= 9 {
commitHashAbbrev = commitHashAbbrev[:9]
}
// Backup path, using Go 1.18's built-in git stamping.
Short = strings.TrimSpace(tailscaleroot.Version) + "-dev" + commitDate

Loading…
Cancel
Save