mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-08 10:51:09 +00:00
Print "version" instead of "Version+Version"
This commit is contained in:
parent
7de805c00f
commit
56985c1093
@ -1,16 +1,15 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is set through ldflags='-X ...' in the Makefile
|
// This is set through ldflags='-X ...' in the Makefile
|
||||||
var taggedRelease string = "Unknown"
|
var taggedRelease string = "unknown"
|
||||||
|
|
||||||
func FormatVersion() string {
|
func FormatVersion() string {
|
||||||
var commitHash string = "Unknown"
|
var commitHash string = ""
|
||||||
var dirty string = ""
|
var dirty string = ""
|
||||||
|
|
||||||
info, ok := debug.ReadBuildInfo()
|
info, ok := debug.ReadBuildInfo()
|
||||||
@ -18,7 +17,10 @@ func FormatVersion() string {
|
|||||||
if ok {
|
if ok {
|
||||||
for _, setting := range info.Settings {
|
for _, setting := range info.Settings {
|
||||||
if setting.Key == "vcs.revision" {
|
if setting.Key == "vcs.revision" {
|
||||||
commitHash = setting.Value
|
commitHash = "+" + setting.Value
|
||||||
|
if len(commitHash) > 8 {
|
||||||
|
commitHash = commitHash[:8]
|
||||||
|
}
|
||||||
} else if setting.Key == "vcs.modified" {
|
} else if setting.Key == "vcs.modified" {
|
||||||
modified, err := strconv.ParseBool(setting.Value)
|
modified, err := strconv.ParseBool(setting.Value)
|
||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
@ -28,5 +30,5 @@ func FormatVersion() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s+%s%s", taggedRelease, commitHash[:7], dirty)
|
return taggedRelease + commitHash + dirty
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user