From 83ccdcd66d8d69a227fe5fdceb5aa25989608866 Mon Sep 17 00:00:00 2001 From: Mark Anderson Date: Thu, 5 May 2022 20:41:18 -0700 Subject: [PATCH] Update version/version.go to match enterprise Signed-off-by: Mark Anderson --- version/version.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/version/version.go b/version/version.go index 962d073010..a878fdaefd 100644 --- a/version/version.go +++ b/version/version.go @@ -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.