From 3eb5f1eb0e1d9a20cfeabd0e2188b986e5c92630 Mon Sep 17 00:00:00 2001 From: Owen Qwen Date: Sun, 28 Jun 2026 16:58:44 -0500 Subject: [PATCH] Fix version injection: don't let VCS revision override ldflags-injected version --- shared/version/version.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shared/version/version.go b/shared/version/version.go index 26c5244..5bde305 100644 --- a/shared/version/version.go +++ b/shared/version/version.go @@ -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" {