mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-21 19:21:39 +00:00
Better semver compliance for version reporting
This commit is contained in:
parent
7a1fd123de
commit
286dd408ae
@ -1,6 +1,12 @@
|
||||
package internal
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// the final version string
|
||||
var version string
|
||||
|
||||
// -ldflags "-X github.com/matrix-org/dendrite/internal.branch=master"
|
||||
var branch string
|
||||
@ -16,12 +22,22 @@ const (
|
||||
)
|
||||
|
||||
func VersionString() string {
|
||||
version := fmt.Sprintf("%d.%d.%d%s", VersionMajor, VersionMinor, VersionPatch, VersionTag)
|
||||
if branch != "" {
|
||||
version += fmt.Sprintf("-%s", branch)
|
||||
}
|
||||
if build != "" {
|
||||
version += fmt.Sprintf("+%s", build)
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
func init() {
|
||||
version = fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
|
||||
if VersionTag != "" {
|
||||
version += "-" + VersionTag
|
||||
}
|
||||
parts := []string{}
|
||||
if build != "" {
|
||||
parts = append(parts, build)
|
||||
}
|
||||
if branch != "" {
|
||||
parts = append(parts, branch)
|
||||
}
|
||||
if len(parts) > 0 {
|
||||
version += "+" + strings.Join(parts, ".")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user