Skip to content

Commit c1f9c2c

Browse files
xnoxcagedmantis
authored andcommitted
[release-branch.go1.24] cmd/go/internal/load: join incompatible and dirty build specifiers with .
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 <[email protected]> Reviewed-by: Sam Thanawalla <[email protected]> Reviewed-by: Sean Liao <[email protected]> Auto-Submit: Sean Liao <[email protected]> Reviewed-by: Michael Matloob <[email protected]> (cherry picked from commit a6e7445) Reviewed-on: https://go-review.googlesource.com/c/go/+/668135
1 parent 0ab64e2 commit c1f9c2c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/cmd/go/internal/load/pkg.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,12 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
25712571
vers := revInfo.Version
25722572
if vers != "" {
25732573
if st.Uncommitted {
2574-
vers += "+dirty"
2574+
// SemVer build metadata is dot-separated https://semver.org/#spec-item-10
2575+
if strings.HasSuffix(vers, "+incompatible") {
2576+
vers += ".dirty"
2577+
} else {
2578+
vers += "+dirty"
2579+
}
25752580
}
25762581
info.Main.Version = vers
25772582
}

src/cmd/go/testdata/script/build_version_stamping_git.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ go version -m example$GOEXE
108108
stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2e239bf29c13\s+'
109109
rm example$GOEXE
110110

111+
# Create +incompatible module
112+
exec git checkout v1.0.4
113+
exec git rm go.mod
114+
exec git commit -m 'commit 6'
115+
exec git tag v2.0.0
116+
exec git checkout HEAD^ go.mod
117+
# And make the tree +dirty
118+
mv README4 README5
119+
go build
120+
go version -m example$GOEXE
121+
stdout '\s+mod\s+example\s+v2.0.0\+incompatible.dirty\s+'
122+
rm example$GOEXE
123+
111124
-- $WORK/repo/go.mod --
112125
module example
113126

0 commit comments

Comments
 (0)