1 [short] skip
2 [!git] skip
3
4 env GO111MODULE=on
5 env GOPROXY=direct
6 env GOSUMDB=off
7
8 # go mod download with the pseudo-version should invoke git but not have a TagSum or Ref.
9 go mod download -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20170922010558-fc3a09f3dc5c
10 stderr 'git( .*)* fetch'
11 cp stdout hellopseudo.json
12 ! stdout '"(Query|TagPrefix|TagSum|Ref)"'
13 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
14 stdout '"VCS": "git"'
15 stdout '"URL": ".*/git/hello"'
16 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
17 go clean -modcache
18
19 # go mod download vcstest/hello should invoke git, print origin info
20 go mod download -x -json vcs-test.golang.org/git/hello.git@latest
21 stderr 'git( .*)* fetch'
22 cp stdout hello.json
23 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
24 stdout '"VCS": "git"'
25 stdout '"URL": ".*/git/hello"'
26 stdout '"Query": "latest"'
27 ! stdout '"TagPrefix"'
28 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
29 stdout '"Ref": "HEAD"'
30 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
31
32 # pseudo-version again should not invoke git fetch (it has the version from the @latest query)
33 # but still be careful not to include a TagSum or a Ref, especially not Ref set to HEAD,
34 # which is easy to do when reusing the cached version from the @latest query.
35 go mod download -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20170922010558-fc3a09f3dc5c
36 ! stderr 'git( .*)* fetch'
37 cp stdout hellopseudo2.json
38 cmpenv hellopseudo.json hellopseudo2.json
39
40 # go mod download vcstest/hello@hash needs to check TagSum to find pseudoversion base.
41 go mod download -x -json vcs-test.golang.org/git/hello.git@fc3a09f3dc5c
42 ! stderr 'git( .*)* fetch'
43 cp stdout hellohash.json
44 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
45 stdout '"Query": "fc3a09f3dc5c"'
46 stdout '"VCS": "git"'
47 stdout '"URL": ".*/git/hello"'
48 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
49 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
50
51 # go mod download vcstest/hello/v9 should fail, still print origin info
52 ! go mod download -x -json vcs-test.golang.org/git/hello.git/v9@latest
53 cp stdout hellov9.json
54 stdout '"Version": "latest"'
55 stdout '"Error":.*no matching versions'
56 ! stdout '"TagPrefix"'
57 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
58 stdout '"Ref": "HEAD"'
59 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
60 ! stdout 'RepoSum'
61
62 # go mod download vcstest/hello/sub/v9 should also fail, print origin info with TagPrefix
63 ! go mod download -x -json vcs-test.golang.org/git/hello.git/sub/v9@latest
64 cp stdout hellosubv9.json
65 stdout '"Version": "latest"'
66 stdout '"Error":.*no matching versions'
67 stdout '"TagPrefix": "sub/"'
68 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
69 stdout '"Ref": "HEAD"'
70 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
71 ! stdout 'RepoSum'
72
73 # go mod download vcstest/hello@nonexist should fail, still print origin info
74 ! go mod download -x -json vcs-test.golang.org/git/hello.git@nonexist
75 cp stdout hellononexist.json
76 stdout '"Version": "nonexist"'
77 stdout '"Error":.*unknown revision nonexist'
78 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
79 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
80
81 # go mod download vcstest/hello@1234567890123456789012345678901234567890 should fail, still print origin info
82 # (40 hex digits is assumed to be a full hash and is a slightly different code path from @nonexist)
83 ! go mod download -x -json vcs-test.golang.org/git/hello.git@1234567890123456789012345678901234567890
84 cp stdout hellononhash.json
85 stdout '"Version": "1234567890123456789012345678901234567890"'
86 stdout '"Error":.*unknown revision 1234567890123456789012345678901234567890'
87 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
88 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
89
90 # go mod download vcstest/hello@v0.0.0-20220101120101-123456789abc should fail, still print origin info
91 # (non-existent pseudoversion)
92 ! go mod download -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20220101120101-123456789abc
93 cp stdout hellononpseudo.json
94 stdout '"Version": "v0.0.0-20220101120101-123456789abc"'
95 stdout '"Error":.*unknown revision 123456789abc'
96 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
97 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
98
99 # go mod download vcstest/tagtests should invoke git, print origin info
100 go mod download -x -json vcs-test.golang.org/git/tagtests.git@latest
101 stderr 'git( .*)* fetch'
102 cp stdout tagtests.json
103 stdout '"Version": "v0.2.2"'
104 stdout '"Query": "latest"'
105 stdout '"VCS": "git"'
106 stdout '"URL": ".*/git/tagtests"'
107 ! stdout '"TagPrefix"'
108 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
109 stdout '"Ref": "refs/tags/v0.2.2"'
110 stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
111
112 # go mod download vcstest/tagtests@v0.2.2 should print origin info, no TagSum needed
113 go mod download -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
114 cp stdout tagtestsv022.json
115 stdout '"Version": "v0.2.2"'
116 ! stdout '"Query":'
117 stdout '"VCS": "git"'
118 stdout '"URL": ".*/git/tagtests"'
119 ! stdout '"TagPrefix"'
120 ! stdout '"TagSum"'
121 stdout '"Ref": "refs/tags/v0.2.2"'
122 stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
123
124 # go mod download vcstest/tagtests@master needs a TagSum again
125 go mod download -x -json vcs-test.golang.org/git/tagtests.git@master
126 cp stdout tagtestsmaster.json
127 stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
128 stdout '"Query": "master"'
129 stdout '"VCS": "git"'
130 stdout '"URL": ".*/git/tagtests"'
131 ! stdout '"TagPrefix"'
132 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
133 stdout '"Ref": "refs/heads/master"'
134 stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
135
136 # go mod download vcstest/prefixtagtests should invoke git, print origin info
137 go mod download -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
138 stderr 'git( .*)* fetch'
139 cp stdout prefixtagtests.json
140 stdout '"Version": "v0.0.10"'
141 stdout '"Query": "latest"'
142 stdout '"VCS": "git"'
143 stdout '"URL": ".*/git/prefixtagtests"'
144 stdout '"Subdir": "sub"'
145 stdout '"TagPrefix": "sub/"'
146 stdout '"TagSum": "t1:YGSbWkJ8dn9ORAr[+]BlKHFK/2ZhXLb9hVuYfTZ9D8C7g="'
147 stdout '"Ref": "refs/tags/sub/v0.0.10"'
148 stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
149
150 # go mod download of a bunch of these should fail (some are invalid) but write good JSON for later
151 ! go mod download -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtests.git@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
152 cp stdout all.json
153
154 # clean the module cache, make sure that makes go mod download re-run git fetch, clean again
155 go clean -modcache
156 go mod download -x -json vcs-test.golang.org/git/hello.git@latest
157 stderr 'git( .*)* fetch'
158 go clean -modcache
159
160 # reuse go mod download vcstest/hello result
161 go mod download -reuse=hello.json -x -json vcs-test.golang.org/git/hello.git@latest
162 ! stderr 'git( .*)* fetch'
163 stdout '"Reuse": true'
164 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
165 stdout '"VCS": "git"'
166 stdout '"URL": ".*/git/hello"'
167 ! stdout '"TagPrefix"'
168 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
169 stdout '"Ref": "HEAD"'
170 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
171 ! stdout '"Dir"'
172 ! stdout '"Info"'
173 ! stdout '"GoMod"'
174 ! stdout '"Zip"'
175
176 # reuse go mod download vcstest/hello pseudoversion result
177 go mod download -reuse=hellopseudo.json -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20170922010558-fc3a09f3dc5c
178 ! stderr 'git( .*)* fetch'
179 stdout '"Reuse": true'
180 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
181 stdout '"VCS": "git"'
182 stdout '"URL": ".*/git/hello"'
183 ! stdout '"(Query|TagPrefix|TagSum|Ref)"'
184 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
185 ! stdout '"(Dir|Info|GoMod|Zip)"'
186
187 # reuse go mod download vcstest/hello@hash
188 go mod download -reuse=hellohash.json -x -json vcs-test.golang.org/git/hello.git@fc3a09f3dc5c
189 ! stderr 'git( .*)* fetch'
190 stdout '"Reuse": true'
191 stdout '"Query": "fc3a09f3dc5c"'
192 stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
193 stdout '"VCS": "git"'
194 stdout '"URL": ".*/git/hello"'
195 ! stdout '"(TagPrefix|Ref)"'
196 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
197 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
198 ! stdout '"(Dir|Info|GoMod|Zip)"'
199
200 # reuse go mod download vcstest/hello/v9 error result
201 ! go mod download -reuse=hellov9.json -x -json vcs-test.golang.org/git/hello.git/v9@latest
202 ! stderr 'git( .*)* fetch'
203 stdout '"Reuse": true'
204 stdout '"Error":.*no matching versions'
205 ! stdout '"TagPrefix"'
206 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
207 stdout '"Ref": "HEAD"'
208 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
209 ! stdout '"(Dir|Info|GoMod|Zip)"'
210
211 # reuse go mod download vcstest/hello/sub/v9 error result
212 ! go mod download -reuse=hellosubv9.json -x -json vcs-test.golang.org/git/hello.git/sub/v9@latest
213 ! stderr 'git( .*)* fetch'
214 stdout '"Reuse": true'
215 stdout '"Error":.*no matching versions'
216 stdout '"TagPrefix": "sub/"'
217 stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
218 stdout '"Ref": "HEAD"'
219 stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
220 ! stdout '"(Dir|Info|GoMod|Zip)"'
221
222 # reuse go mod download vcstest/hello@nonexist
223 ! go mod download -reuse=hellononexist.json -x -json vcs-test.golang.org/git/hello.git@nonexist
224 ! stderr 'git( .*)* fetch'
225 stdout '"Reuse": true'
226 stdout '"Version": "nonexist"'
227 stdout '"Error":.*unknown revision nonexist'
228 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
229 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
230 ! stdout '"(Dir|Info|GoMod|Zip)"'
231
232 # reuse go mod download vcstest/hello@1234567890123456789012345678901234567890
233 ! go mod download -reuse=hellononhash.json -x -json vcs-test.golang.org/git/hello.git@1234567890123456789012345678901234567890
234 ! stderr 'git( .*)* fetch'
235 stdout '"Reuse": true'
236 stdout '"Version": "1234567890123456789012345678901234567890"'
237 stdout '"Error":.*unknown revision 1234567890123456789012345678901234567890'
238 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
239 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
240 ! stdout '"(Dir|Info|GoMod|Zip)"'
241
242 # reuse go mod download vcstest/hello@v0.0.0-20220101120101-123456789abc
243 ! go mod download -reuse=hellononpseudo.json -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20220101120101-123456789abc
244 ! stderr 'git( .*)* fetch'
245 stdout '"Reuse": true'
246 stdout '"Version": "v0.0.0-20220101120101-123456789abc"'
247 stdout '"Error":.*unknown revision 123456789abc'
248 stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
249 ! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
250 ! stdout '"(Dir|Info|GoMod|Zip)"'
251
252 # reuse go mod download vcstest/tagtests result
253 go mod download -reuse=tagtests.json -x -json vcs-test.golang.org/git/tagtests.git@latest
254 ! stderr 'git( .*)* fetch'
255 stdout '"Reuse": true'
256 stdout '"Version": "v0.2.2"'
257 stdout '"Query": "latest"'
258 stdout '"VCS": "git"'
259 stdout '"URL": ".*/git/tagtests"'
260 ! stdout '"TagPrefix"'
261 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
262 stdout '"Ref": "refs/tags/v0.2.2"'
263 stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
264 ! stdout '"(Dir|Info|GoMod|Zip)"'
265
266 # reuse go mod download vcstest/tagtests@v0.2.2 result
267 go mod download -reuse=tagtestsv022.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
268 ! stderr 'git( .*)* fetch'
269 stdout '"Reuse": true'
270 stdout '"Version": "v0.2.2"'
271 ! stdout '"Query":'
272 stdout '"VCS": "git"'
273 stdout '"URL": ".*/git/tagtests"'
274 ! stdout '"TagPrefix"'
275 ! stdout '"TagSum"'
276 stdout '"Ref": "refs/tags/v0.2.2"'
277 stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
278 ! stdout '"(Dir|Info|GoMod|Zip)"'
279
280 # reuse go mod download vcstest/tagtests@master result
281 go mod download -reuse=tagtestsmaster.json -x -json vcs-test.golang.org/git/tagtests.git@master
282 ! stderr 'git( .*)* fetch'
283 stdout '"Reuse": true'
284 stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
285 stdout '"Query": "master"'
286 stdout '"VCS": "git"'
287 stdout '"URL": ".*/git/tagtests"'
288 ! stdout '"TagPrefix"'
289 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
290 stdout '"Ref": "refs/heads/master"'
291 stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
292 ! stdout '"(Dir|Info|GoMod|Zip)"'
293
294 # reuse go mod download vcstest/tagtests@master result again with all.json
295 go mod download -reuse=all.json -x -json vcs-test.golang.org/git/tagtests.git@master
296 ! stderr 'git( .*)* fetch'
297 stdout '"Reuse": true'
298 stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
299 stdout '"Query": "master"'
300 stdout '"VCS": "git"'
301 stdout '"URL": ".*/git/tagtests"'
302 ! stdout '"TagPrefix"'
303 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
304 stdout '"Ref": "refs/heads/master"'
305 stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
306 ! stdout '"(Dir|Info|GoMod|Zip)"'
307
308 # go mod download vcstest/prefixtagtests result with json
309 go mod download -reuse=prefixtagtests.json -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
310 ! stderr 'git( .*)* fetch'
311 stdout '"Version": "v0.0.10"'
312 stdout '"Query": "latest"'
313 stdout '"VCS": "git"'
314 stdout '"URL": ".*/git/prefixtagtests"'
315 stdout '"Subdir": "sub"'
316 stdout '"TagPrefix": "sub/"'
317 stdout '"TagSum": "t1:YGSbWkJ8dn9ORAr[+]BlKHFK/2ZhXLb9hVuYfTZ9D8C7g="'
318 stdout '"Ref": "refs/tags/sub/v0.0.10"'
319 stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
320 ! stdout '"(Dir|Info|GoMod|Zip)"'
321
322 # reuse the bulk results with all.json
323 ! go mod download -reuse=all.json -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtests.git@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
324 ! stderr 'git( .*)* fetch'
325 stdout '"Reuse": true'
326 ! stdout '"(Dir|Info|GoMod|Zip)"'
327
328 # reuse attempt with stale hash should reinvoke git, not report reuse
329 cp tagtestsv022.json tagtestsv022badhash.json
330 replace '57952' '56952XXX' tagtestsv022badhash.json
331 go mod download -reuse=tagtestsv022badhash.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
332 stderr 'git( .*)* fetch'
333 ! stdout '"Reuse": true'
334 stdout '"Version": "v0.2.2"'
335 ! stdout '"Query"'
336 stdout '"VCS": "git"'
337 stdout '"URL": ".*/git/tagtests"'
338 ! stdout '"(TagPrefix|TagSum)"'
339 stdout '"Ref": "refs/tags/v0.2.2"'
340 stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
341 stdout '"Dir"'
342 stdout '"Info"'
343 stdout '"GoMod"'
344 stdout '"Zip"'
345
346 # reuse with stale repo URL
347 cp tagtestsv022.json tagtestsv022badurl.json
348 replace 'git/tagtests\"' 'git/tagtestsXXX\"' tagtestsv022badurl.json
349 go mod download -reuse=tagtestsv022badurl.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
350 ! stdout '"Reuse": true'
351 stdout '"URL": ".*/git/tagtests"'
352 stdout '"Dir"'
353 stdout '"Info"'
354 stdout '"GoMod"'
355 stdout '"Zip"'
356
357 # reuse with stale VCS
358 cp tagtestsv022.json tagtestsv022badvcs.json
359 replace '\"git\"' '\"gitXXX\"' tagtestsv022badvcs.json
360 go mod download -reuse=tagtestsv022badvcs.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
361 ! stdout '"Reuse": true'
362 stdout '"URL": ".*/git/tagtests"'
363
364 # reuse with stale Dir
365 cp tagtestsv022.json tagtestsv022baddir.json
366 replace '\t\t\"Ref\":' '\t\t\"Subdir\": \"subdir\",\n\t\t\"Ref\":' tagtestsv022baddir.json
367 go mod download -reuse=tagtestsv022baddir.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
368 ! stdout '"Reuse": true'
369 stdout '"URL": ".*/git/tagtests"'
370
371 # reuse with stale TagSum
372 cp tagtests.json tagtestsbadtagsum.json
373 replace 'sMEOGo=' 'sMEoGo=XXX' tagtestsbadtagsum.json
374 go mod download -reuse=tagtestsbadtagsum.json -x -json vcs-test.golang.org/git/tagtests.git@latest
375 ! stdout '"Reuse": true'
376 stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
377
View as plain text