aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_retract_replace.txt
blob: 7aec438ddaef9da6406f63bcab54068c4ba1c9d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# If the latest unretracted version of a module is replaced, 'go list' should
# obtain retractions from the replacement.

# Populate go.sum.
go get -d

# The latest version, v1.9.0, is not available on the proxy.
! go list -m -retracted example.com/retract/missingmod
stderr '^go list -m: loading module retractions: example.com/retract/missingmod@v1.9.0:.*404 Not Found$'

# If we replace that version, we should see retractions.
go mod edit -replace=example.com/retract/missingmod@v1.9.0=./missingmod-v1.9.0
go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract/missingmod
stdout '^bad version$'

# If we replace the retracted version, we should not see a retraction.
go mod edit -replace=example.com/retract/missingmod=./missingmod-v1.9.0
go list -m -retracted -f '{{if not .Retracted}}good version{{end}}' example.com/retract/missingmod
stdout '^good version$'


# If a replacement version is retracted, we should see a retraction.
# It should appear in both the replaced module and the replacement, as other
# fields like GoMod do.
go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract
! stdout .
go list -m -retracted -f '{{if .Replace}}replaced{{end}}' example.com/retract
! stdout .
go mod edit -replace example.com/retract@v1.0.0-good=example.com/retract@v1.0.0-bad
go list -m -mod=mod -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract
stdout '^bad$'
go list -m -mod=mod -retracted -f '{{with .Replace}}{{range .Retracted}}{{.}}{{end}}{{end}}' example.com/retract
stdout '^bad$'

-- go.mod --
module m

go 1.14

require (
	example.com/retract v1.0.0-good
	example.com/retract/missingmod v1.0.0
)
-- use.go --
package use

import (
	_ "example.com/retract"
	_ "example.com/retract/missingmod"
)
-- missingmod-v1.0.0/go.mod --
module example.com/retract/missingmod

go 1.14
-- missingmod-v1.9.0/go.mod --
module example.com/retract/missingmod

go 1.14

// bad version
retract v1.0.0