Update version/version.go to match enterprise

Signed-off-by: Mark Anderson <manderson@hashicorp.com>
This commit is contained in:
Mark Anderson 2022-05-05 20:41:18 -07:00
parent 785a6d9c8e
commit 4983d1b335
1 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package version
import (
"fmt"
"strings"
)
@ -15,6 +16,9 @@ var (
// for tests to work.
Version = "1.12.0"
// https://semver.org/#spec-item-10
VersionMetadata = ""
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc.
@ -26,13 +30,14 @@ var (
func GetHumanVersion() string {
version := Version
release := VersionPrerelease
metadata := VersionMetadata
if release != "" {
suffix := "-" + release
if !strings.HasSuffix(version, suffix) {
// if we tagged a prerelease version then the release is in the version already
version += suffix
}
version += fmt.Sprintf("-%s", release)
}
if metadata != "" {
version += fmt.Sprintf("+%s", metadata)
}
// Strip off any single quotes added by the git information.