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()
|
flag.Parse()
|
||||||
|
|
||||||
if *showVersion {
|
if *showVersion {
|
||||||
fmt.Printf("ChronoTomato v%v\n", metadata.ChronoTomatoVersion)
|
fmt.Println("ChronoTomato", metadata.ChronoTomatoVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ChronoTomatoVersion = "" // The GoTomato version
|
var ChronoTomatoVersion = ""
|
||||||
|
|
||||||
func stripVersionPrefix(version string) string {
|
|
||||||
return strings.TrimLeft(version, "v")
|
|
||||||
}
|
|
||||||
|
|
||||||
func getLatestTag() string {
|
func getLatestTag() string {
|
||||||
bytes, _ := exec.Command("git", "describe", "--tags").Output()
|
bytes, _ := exec.Command("git", "describe", "--tags").Output()
|
||||||
output := strings.TrimSpace(string(bytes))
|
output := strings.TrimSpace(string(bytes))
|
||||||
return stripVersionPrefix(output)
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
// set GoTomatoVersion from runtime/debug.Main.Version
|
// set GoTomatoVersion from runtime/debug.Main.Version
|
||||||
|
@ -25,7 +21,7 @@ func init() {
|
||||||
if ChronoTomatoVersion == "" {
|
if ChronoTomatoVersion == "" {
|
||||||
info, _ := debug.ReadBuildInfo()
|
info, _ := debug.ReadBuildInfo()
|
||||||
if info.Main.Version != "(devel)" {
|
if info.Main.Version != "(devel)" {
|
||||||
ChronoTomatoVersion = stripVersionPrefix(info.Main.Version)
|
ChronoTomatoVersion = info.Main.Version
|
||||||
} else {
|
} else {
|
||||||
ChronoTomatoVersion = getLatestTag()
|
ChronoTomatoVersion = getLatestTag()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue