@@ -34,14 +34,14 @@ exec git branch -m main
34
34
# Use a 0.0.0 pseudo-version when no tags are present.
35
35
go build
36
36
go version -m example$GOEXE
37
- stdout '\s+mod\s+example\s+v0.0.0-20220719150700-b52f952448d2 \s+'
37
+ stdout '\s+mod\s+example\s+v0.0.0-20220719150700-e7537ba8fd6d \s+'
38
38
rm example$GOEXE
39
39
40
40
# Use a 0.0.0 pseudo-version if the current tag is not a valid semantic version.
41
41
exec git tag 1.0.1
42
42
go build
43
43
go version -m example$GOEXE
44
- stdout '\s+mod\s+example\s+v0.0.0-20220719150700-b52f952448d2 \s+'
44
+ stdout '\s+mod\s+example\s+v0.0.0-20220719150700-e7537ba8fd6d \s+'
45
45
rm example$GOEXE
46
46
47
47
# Use the current tag which has a valid semantic version to stamp the version.
@@ -79,14 +79,14 @@ exec git commit -m 'commit 3'
79
79
# Use a pseudo-version when current commit doesn't match a tagged version.
80
80
go build
81
81
go version -m example$GOEXE
82
- stdout '\s+mod\s+example\s+v1.0.3-0.20220719150702-deaeab06f7fe \s+'
82
+ stdout '\s+mod\s+example\s+v1.0.3-0.20220719150702-b0226f18a7ae \s+'
83
83
rm example$GOEXE
84
84
85
85
# Use pseudo+dirty when uncommitted changes are present.
86
86
mv README2 README3
87
87
go build
88
88
go version -m example$GOEXE
89
- stdout '\s+mod\s+example\s+v1.0.3-0.20220719150702-deaeab06f7fe \+dirty\s+'
89
+ stdout '\s+mod\s+example\s+v1.0.3-0.20220719150702-b0226f18a7ae \+dirty\s+'
90
90
rm example$GOEXE
91
91
92
92
# Make sure we always use the previously tagged version to generate the pseudo-version at a untagged revision.
@@ -105,7 +105,7 @@ exec git tag v1.0.4
105
105
exec git checkout ':/commit 4'
106
106
go build
107
107
go version -m example$GOEXE
108
- stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2e239bf29c13 \s+'
108
+ stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2ebc76937b49 \s+'
109
109
rm example$GOEXE
110
110
111
111
# Create +incompatible module
@@ -121,6 +121,67 @@ go version -m example$GOEXE
121
121
stdout '\s+mod\s+example\s+v2.0.0\+incompatible.dirty\s+'
122
122
rm example$GOEXE
123
123
124
+ # Make sure v2 works as expected.
125
+ exec git checkout v1.0.4
126
+ go mod edit -module example/v2
127
+ exec git add .
128
+ exec git commit -m 'commit 7'
129
+ exec git tag v2.1.1
130
+ go build
131
+ go version -m example$GOEXE
132
+ stdout '\s+mod\s+example/v2\s+v2.1.1\s+'
133
+ rm example$GOEXE
134
+
135
+ # v2+dirty
136
+ mv README5 README6
137
+ go build
138
+ go version -m example$GOEXE
139
+ stdout '\s+mod\s+example/v2\s+v2.1.1\+dirty\s+'
140
+ rm example$GOEXE
141
+
142
+ # v2+pseudo
143
+ exec git add .
144
+ exec git commit -m 'commit 8'
145
+ go build
146
+ go version -m example$GOEXE
147
+ stdout '\s+mod\s+example/v2\s+v2.1.2-0.20220719150704-0ebeb94ecde2\s+'
148
+ rm example$GOEXE
149
+
150
+ # v2+pseudo+dirty
151
+ mv README6 README7
152
+ go build
153
+ go version -m example$GOEXE
154
+ stdout '\s+mod\s+example/v2\s+v2.1.2-0.20220719150704-0ebeb94ecde2\+dirty\s+'
155
+ rm example$GOEXE
156
+
157
+ # modules in subdirectories should be stamped with the correct tag
158
+ exec git add .
159
+ cd subdir
160
+ exec git commit -m 'commit 9'
161
+ go build
162
+ go version -m subdir$GOEXE
163
+ # missing tag creates a pseudo version with v2.0.0
164
+ stdout '\s+mod\s+example/subdir/v2\s+v2.0.0-20220719150704-fbef6799938f\s+'
165
+ rm subdir$GOEXE
166
+ # tag with subdir
167
+ exec git tag subdir/v2.1.0
168
+ go build
169
+ go version -m subdir$GOEXE
170
+ stdout '\s+mod\s+example/subdir/v2\s+v2.1.0\s+'
171
+ # v2+dirty
172
+ mv ../README7 README8
173
+ go build
174
+ go version -m subdir$GOEXE
175
+ stdout '\s+mod\s+example/subdir/v2\s+v2.1.0\+dirty\s+'
176
+ rm subdir$GOEXE
177
+
178
+ # modules in a subdirectory without a go.mod in the root should result in (devel)
179
+ rm ../go.mod
180
+ go build
181
+ go version -m subdir$GOEXE
182
+ stdout '\s+mod\s+example/subdir/v2\s+\(devel\)\s+'
183
+ rm subdir$GOEXE
184
+
124
185
-- $WORK/repo/go.mod --
125
186
module example
126
187
@@ -133,6 +194,17 @@ func main() {
133
194
-- $WORK/copy/README --
134
195
hello
135
196
197
+ -- $WORK/repo/subdir/go.mod --
198
+ module example/subdir/v2
199
+
200
+ go 1.18
201
+
202
+ -- $WORK/repo/subdir/main.go --
203
+ package main
204
+
205
+ func main() {
206
+ }
207
+
136
208
-- $WORK/home/gopher/.gitconfig --
137
209
[user]
138
210
name = Go Gopher
0 commit comments