aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_get_patch.txt
blob: 5957a360b06e7bdcce1b21eb09f4825d22b2a383 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# This test examines the behavior of 'go get …@patch'
# See also mod_upgrade_patch.txt (focused on "-u=patch" specifically)
# and mod_get_patchmod.txt (focused on module/package ambiguities).

cp go.mod go.mod.orig

# example.net/b@patch refers to the patch for the version of b that was selected
# at the start of 'go get', not the version after applying other changes.

! go get -d example.net/a@v0.2.0 example.net/b@patch
stderr '^go: example.net/a@v0.2.0 requires example.net/b@v0.2.0, not example.net/b@patch \(v0.1.1\)$'
cmp go.mod go.mod.orig


# -u=patch changes the default version for other arguments to '@patch',
# but they continue to be resolved against the originally-selected version,
# not the updated one.
#
# TODO(#42360): Reconsider the change in defaults.

! go get -d -u=patch example.net/a@v0.2.0 example.net/b
stderr '^go: example.net/a@v0.2.0 requires example.net/b@v0.2.0, not example.net/b@patch \(v0.1.1\)$'
cmp go.mod go.mod.orig


# -u=patch refers to the patches for the selected versions of dependencies *after*
# applying other version changes, not the versions that were selected at the start.
# However, it should not patch versions determined by explicit arguments.

go get -d -u=patch example.net/a@v0.2.0
go list -m all
stdout '^example.net/a v0.2.0 '
stdout '^example.net/b v0.2.1 '


# "-u=patch all" should be equivalent to "all@patch", and should fail if the
# patched versions result in a higher-than-patch upgrade.

cp go.mod.orig go.mod
! go get -u=patch all
stderr '^go: example.net/a@v0.1.1 \(matching all@patch\) requires example.net/b@v0.2.0, not example.net/b@v0.1.1 \(matching all@patch\)$'
cmp go.mod go.mod.orig


# On the other hand, "-u=patch ./..." should patch-upgrade dependencies until
# they reach a fixed point, even if that results in higher-than-patch upgrades.

go get -u=patch ./...
go list -m all
stdout '^example.net/a v0.1.1 '
stdout '^example.net/b v0.2.1 '


-- go.mod --
module example

go 1.16

require (
	example.net/a v0.1.0
	example.net/b v0.1.0  // indirect
)

replace (
	example.net/a v0.1.0 => ./a10
	example.net/a v0.1.1 => ./a11
	example.net/a v0.2.0 => ./a20
	example.net/a v0.2.1 => ./a21
	example.net/b v0.1.0 => ./b
	example.net/b v0.1.1 => ./b
	example.net/b v0.2.0 => ./b
	example.net/b v0.2.1 => ./b
	example.net/b v0.3.0 => ./b
	example.net/b v0.3.1 => ./b
)
-- example.go --
package example

import _ "example.net/a"

-- a10/go.mod --
module example.net/a

go 1.16

require example.net/b v0.1.0
-- a10/a.go --
package a

import _ "example.net/b"

-- a11/go.mod --
module example.net/a

go 1.16

require example.net/b v0.2.0  // upgraded
-- a11/a.go --
package a

import _ "example.net/b"

-- a20/go.mod --
module example.net/a

go 1.16

require example.net/b v0.2.0
-- a20/a.go --
package a

import _ "example.net/b"

-- a21/go.mod --
module example.net/a

go 1.16

require example.net/b v0.2.0  // not upgraded
-- a21/a.go --
package a

import _ "example.net/b"

-- b/go.mod --
module example.net/b

go 1.16
-- b/b.go --
package b