1
0
mirror of https://github.com/golang/go synced 2024-11-26 07:47:57 -07:00

cmd/go: ensure 'go get -u' can upgrade pruned (1.17+) modules

Fixes #47768

Change-Id: I981a31ba4ff716570ac4c6f35b289fa480faa5bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/343879
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Jay Conrod 2021-08-20 14:38:09 -07:00
parent b602daea1b
commit bdc1bef8a0
2 changed files with 69 additions and 0 deletions

View File

@ -237,6 +237,7 @@ func raiseLimitsForUpgrades(ctx context.Context, maxVersion map[string]string, d
continue
}
allow(m)
for _, r := range summary.require {
allow(r)
}

View File

@ -0,0 +1,68 @@
# Check that 'go get -u' will upgrade a dependency (direct or indirect)
# when the main module and the dependency are both lazy.
# Verifies #47768.
# Check that go.mod is tidy, and an upgrade is available.
cp go.mod go.mod.orig
go mod tidy
cmp go.mod go.mod.orig
go list -m -u example.com/lazyupgrade
stdout '^example.com/lazyupgrade v0.1.0 \[v0.1.1\] => ./lazyupgrade@v0.1.0$'
# 'go get -u' on a package that directly imports the dependency should upgrade.
go get -u ./usedirect
go list -m example.com/lazyupgrade
stdout '^example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1$'
cp go.mod.orig go.mod
# 'go get -u' on a package that indirectly imports the dependency should upgrade.
go get -u ./useindirect
go list -m example.com/lazyupgrade
stdout '^example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1$'
-- go.mod --
module use
go 1.17
require (
direct v0.0.0
example.com/lazyupgrade v0.1.0
)
replace (
direct => ./direct
example.com/lazyupgrade v0.1.0 => ./lazyupgrade@v0.1.0
example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1
)
-- usedirect/usedirect.go --
package use
import _ "example.com/lazyupgrade"
-- useindirect/useindirect.go --
package use
import _ "direct"
-- direct/go.mod --
module direct
go 1.17
require example.com/lazyupgrade v0.1.0
-- direct/direct.go --
package direct
import _ "example.com/lazyupgrade"
-- lazyupgrade@v0.1.0/go.mod --
module example.com/lazyupgrade
go 1.17
-- lazyupgrade@v0.1.0/lazyupgrade.go --
package lazyupgrade
-- lazyupgrade@v0.1.1/go.mod --
module example.com/lazyupgrade
go 1.17
-- lazyupgrade@v0.1.1/lazyupgrade.go --
package lazyupgrade