Fix version injection: don't let VCS revision override ldflags-injected version

This commit is contained in:
2026-06-28 16:58:44 -05:00
parent 981587e83d
commit 3eb5f1eb0e
+8 -2
View File
@@ -3,11 +3,17 @@ package version
import "runtime/debug"
// Version is the urapt build version. It is populated from VCS info when
// available, otherwise it falls back to "dev".
// Version is the urapt build version. It can be set at build time via
// -ldflags "-X urapt/shared/version.Version=v0.1.0"; otherwise it is
// populated from VCS info (the current commit) when available, and finally
// falls back to "dev".
var Version = "dev"
func init() {
// If a version was injected via ldflags, honor it and do not override.
if Version != "dev" {
return
}
if info, ok := debug.ReadBuildInfo(); ok {
for _, s := range info.Settings {
if s.Key == "vcs.revision" {