Skip to content

Commit

Permalink
chore: update version string
Browse files Browse the repository at this point in the history
  • Loading branch information
thezzisu committed Mar 20, 2024
1 parent fd848d5 commit fbe167f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions common/version.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package common

import (
"fmt"
"runtime/debug"
)

func GetVersion() string {
if info, ok := debug.ReadBuildInfo(); ok {
settings := make(map[string]string)
for _, setting := range info.Settings {
settings[setting.Key] = setting.Value
version := "azukiiro/"
if info.Main.Version == "(devel)" {
version += "devel"
} else {
version += info.Main.Version
}
hash, ok := settings["vcs.revision"]
if !ok {
return "azukiiro/unknown"
version += " ("
version += info.Main.Path
for _, setting := range info.Settings {
switch setting.Key {
case "vcs.revision":
version += "; " + setting.Value[:7]
case "vcs.modified":
if setting.Value == "true" {
version += "; modified"
}
}
}
hash = hash[:7]
return fmt.Sprintf("azukiiro/%s %s@%s", hash, info.Main.Version, settings["vcs.time"])
version += ")"
return version
}
return "azukiiro/unknown"
}

0 comments on commit fbe167f

Please sign in to comment.