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>
This commit is contained in:
parent
2a1f1c79ca
commit
eb682d2a0b
|
@ -41,14 +41,11 @@ func init() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var dirty string // "-dirty" suffix if dirty
|
var dirty string // "-dirty" suffix if dirty
|
||||||
var commitHashAbbrev, commitDate string
|
var commitDate string
|
||||||
for _, s := range bi.Settings {
|
for _, s := range bi.Settings {
|
||||||
switch s.Key {
|
switch s.Key {
|
||||||
case "vcs.revision":
|
case "vcs.revision":
|
||||||
GitCommit = s.Value
|
GitCommit = s.Value
|
||||||
if len(s.Value) >= 9 {
|
|
||||||
commitHashAbbrev = s.Value[:9]
|
|
||||||
}
|
|
||||||
case "vcs.time":
|
case "vcs.time":
|
||||||
if len(s.Value) >= len("yyyy-mm-dd") {
|
if len(s.Value) >= len("yyyy-mm-dd") {
|
||||||
commitDate = 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.
|
// Backup path, using Go 1.18's built-in git stamping.
|
||||||
Short = strings.TrimSpace(tailscaleroot.Version) + "-dev" + commitDate
|
Short = strings.TrimSpace(tailscaleroot.Version) + "-dev" + commitDate
|
||||||
|
|
Loading…
Reference in New Issue