From 2c6dc32f5d19789ba7357da7311ba8c3ea3ea49c Mon Sep 17 00:00:00 2001 From: niten94 <127052329+niten94@users.noreply.github.com> Date: Wed, 23 Oct 2024 04:07:30 +0800 Subject: [PATCH] Set version as release when there are no commits ahead (#3515) Print release version tag in tools/build-version.go even if the commit being checked has a tag that is not a version number if there are no commits ahead. --- tools/build-version.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/build-version.go b/tools/build-version.go index f0f7a8f84..e9d0cdda6 100644 --- a/tools/build-version.go +++ b/tools/build-version.go @@ -47,15 +47,16 @@ func main() { fmt.Println("0.0.0-unknown") return } - // Get the tag of the current revision. - tag, _ := getTag("--exact-match") - if tag == versionStr { + if ahead == nil { // Seems that we are going to build a release. // So the version number should already be correct. fmt.Println(version.String()) return } + // Get the tag of the current revision. + tag, _ := getTag("--exact-match") + // If we don't have any tag assume "dev" if tag == "" || strings.HasPrefix(tag, "nightly") { tag = "dev" @@ -72,10 +73,8 @@ func main() { log.Printf("semver.NewPRVersion(%s): %v", tag, err) } - if ahead != nil { - // if we know how many commits we are ahead of the last release, append that too. - version.Pre = append(version.Pre, *ahead) - } + // append how many commits we are ahead of the last release + version.Pre = append(version.Pre, *ahead) fmt.Println(version.String()) }