Compare commits
3 commits
7c2604c0bf
...
f8e8bb04a0
Author | SHA1 | Date | |
---|---|---|---|
f8e8bb04a0 | |||
10021eb65e | |||
09dbf35a6a |
2 changed files with 4 additions and 8 deletions
|
@ -76,7 +76,7 @@ func Start() {
|
|||
flag.Parse()
|
||||
|
||||
if *showVersion {
|
||||
fmt.Printf("ChronoTomato v%v\n", metadata.ChronoTomatoVersion)
|
||||
fmt.Println("ChronoTomato", metadata.ChronoTomatoVersion)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,12 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var ChronoTomatoVersion = "" // The GoTomato version
|
||||
|
||||
func stripVersionPrefix(version string) string {
|
||||
return strings.TrimLeft(version, "v")
|
||||
}
|
||||
var ChronoTomatoVersion = ""
|
||||
|
||||
func getLatestTag() string {
|
||||
bytes, _ := exec.Command("git", "describe", "--tags").Output()
|
||||
output := strings.TrimSpace(string(bytes))
|
||||
return stripVersionPrefix(output)
|
||||
return output
|
||||
}
|
||||
|
||||
// set GoTomatoVersion from runtime/debug.Main.Version
|
||||
|
@ -25,7 +21,7 @@ func init() {
|
|||
if ChronoTomatoVersion == "" {
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
if info.Main.Version != "(devel)" {
|
||||
ChronoTomatoVersion = stripVersionPrefix(info.Main.Version)
|
||||
ChronoTomatoVersion = info.Main.Version
|
||||
} else {
|
||||
ChronoTomatoVersion = getLatestTag()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue