]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.24] cmd/go/internal/load: join incompatible and dirty build speci...
authorDimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Tue, 19 Jul 2022 15:07:00 +0000 (11:07 -0400)
committerCarlos Amedee <carlos@golang.org>
Mon, 28 Apr 2025 20:41:55 +0000 (13:41 -0700)
Change "+incompatible+dirty" version to be "+incompatible.dirty" such
that it is SemVer spec compatible.

Fixes #73500

Change-Id: I714ffb3f1ad88c793656c3652367db34739a2144
Reviewed-on: https://go-review.googlesource.com/c/go/+/652955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit a6e74454577c68ea96ce6512e3e92beffbe15c5c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/668135

src/cmd/go/internal/load/pkg.go
src/cmd/go/testdata/script/build_version_stamping_git.txt

index 15f6b2e87b916b97ab26784a3d9ffac3b93196e7..6dd610f2e7d7ab43364be9c02a0c78dbf6ad8930 100644 (file)
@@ -2571,7 +2571,12 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
                vers := revInfo.Version
                if vers != "" {
                        if st.Uncommitted {
-                               vers += "+dirty"
+                               // SemVer build metadata is dot-separated https://semver.org/#spec-item-10
+                               if strings.HasSuffix(vers, "+incompatible") {
+                                       vers += ".dirty"
+                               } else {
+                                       vers += "+dirty"
+                               }
                        }
                        info.Main.Version = vers
                }
index db804b3847996065f848b356a34fc6b0304d65c8..e9aa824474bb58eabb25de9ceda4c8c4208d923e 100644 (file)
@@ -108,6 +108,19 @@ go version -m example$GOEXE
 stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2e239bf29c13\s+'
 rm example$GOEXE
 
+# Create +incompatible module
+exec git checkout v1.0.4
+exec git rm go.mod
+exec git commit -m 'commit 6'
+exec git tag v2.0.0
+exec git checkout HEAD^ go.mod
+# And make the tree +dirty
+mv README4 README5
+go build
+go version -m example$GOEXE
+stdout '\s+mod\s+example\s+v2.0.0\+incompatible.dirty\s+'
+rm example$GOEXE
+
 -- $WORK/repo/go.mod --
 module example