only use short commit string

This commit is contained in:
nouryxd 2024-07-19 22:43:55 +02:00
parent ce701c2230
commit a44cab6b3f

View file

@ -7,15 +7,13 @@
package common package common
import ( import (
"fmt"
"runtime/debug" "runtime/debug"
) )
// GetVersion returns the current git commit hash. // GetVersion returns the current git commit hash.
// If the version is modified the hash ends in "-dirty"
func GetVersion() string { func GetVersion() string {
var revision string var revision string
var modified bool var short string
bi, ok := debug.ReadBuildInfo() bi, ok := debug.ReadBuildInfo()
if ok { if ok {
@ -23,10 +21,7 @@ func GetVersion() string {
switch s.Key { switch s.Key {
case "vcs.revision": case "vcs.revision":
revision = s.Value revision = s.Value
case "vcs.modified": short = revision[:7]
if s.Value == "true" {
modified = true
}
} }
} }
} }
@ -35,11 +30,7 @@ func GetVersion() string {
return "unavailable" return "unavailable"
} }
if modified { return short
return fmt.Sprintf("%s-dirty", revision)
}
return revision
} }
// GetVersion returns the current git commit hash. // GetVersion returns the current git commit hash.