Fix +dev suffix in version

This commit is contained in:
Tulir Asokan 2020-06-03 20:44:52 +03:00
parent 09385713de
commit f3793309a0
2 changed files with 4 additions and 7 deletions

View file

@ -179,13 +179,10 @@ func (handler *CommandHandler) CommandDevTest(_ *CommandEvent) {
const cmdVersionHelp = `version - View the bridge version` const cmdVersionHelp = `version - View the bridge version`
func (handler *CommandHandler) CommandVersion(ce *CommandEvent) { func (handler *CommandHandler) CommandVersion(ce *CommandEvent) {
version := fmt.Sprintf("%s+dev.unknown", Version) version := fmt.Sprintf("%s.unknown", Version)
if Tag == Version { if Tag == Version {
version = fmt.Sprintf("[%s](%s/releases/%s) (%s)", Version, URL, Tag, BuildTime) version = fmt.Sprintf("[%s](%s/releases/%s) (%s)", Version, URL, Tag, BuildTime)
} else if len(Commit) > 8 { } else if len(Commit) > 8 {
if !strings.HasSuffix(Version, "+dev") {
Version += "+dev"
}
version = fmt.Sprintf("%s.[%s](%s/commit/%s) (%s)", Version, Commit[:8], URL, Commit, BuildTime) version = fmt.Sprintf("%s.[%s](%s/commit/%s) (%s)", Version, Commit[:8], URL, Commit, BuildTime)
} }
ce.Reply(fmt.Sprintf("[%s](%s) %s", Name, URL, version)) ce.Reply(fmt.Sprintf("[%s](%s) %s", Name, URL, version))

View file

@ -55,6 +55,9 @@ func init() {
if len(Tag) > 0 && Tag[0] == 'v' { if len(Tag) > 0 && Tag[0] == 'v' {
Tag = Tag[1:] Tag = Tag[1:]
} }
if Tag != Version && !strings.HasSuffix(Version, "+dev") {
Version += "+dev"
}
} }
var configPath = flag.MakeFull("c", "config", "The path to your config file.", "config.yaml").String() var configPath = flag.MakeFull("c", "config", "The path to your config file.", "config.yaml").String()
@ -371,9 +374,6 @@ func (bridge *Bridge) Main() {
if Tag == Version { if Tag == Version {
fmt.Printf("%s %s (%s)\n", Name, Tag, BuildTime) fmt.Printf("%s %s (%s)\n", Name, Tag, BuildTime)
} else if len(Commit) > 8 { } else if len(Commit) > 8 {
if !strings.HasSuffix(Version, "+dev") {
Version += "+dev"
}
fmt.Printf("%s %s.%s (%s)\n", Name, Version, Commit[:8], BuildTime) fmt.Printf("%s %s.%s (%s)\n", Name, Version, Commit[:8], BuildTime)
} else { } else {
fmt.Printf("%s %s+dev.unknown\n", Name, Version) fmt.Printf("%s %s+dev.unknown\n", Name, Version)