Skip to content

Set version as release when there are no commits ahead #3515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions tools/build-version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())
}