mirror of
https://github.com/golang/go
synced 2024-07-25 03:55:34 +00:00
cmd/go: avoid re-enqueuing workspace dependencies with errors
Fixes #53874. Change-Id: I41ab15cb9b86b807a9d9ad21fe21fb7aa5fbb46f Reviewed-on: https://go-review.googlesource.com/c/go/+/417594 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
266c70c263
commit
a906d3dd09
|
@ -397,7 +397,6 @@ func readModGraph(ctx context.Context, pruning modPruning, roots []module.Versio
|
||||||
seen := map[module.Version]bool{}
|
seen := map[module.Version]bool{}
|
||||||
for _, m := range roots {
|
for _, m := range roots {
|
||||||
hasDepsInAll[m.Path] = true
|
hasDepsInAll[m.Path] = true
|
||||||
seen[m] = true
|
|
||||||
}
|
}
|
||||||
// This loop will terminate because it will call enqueue on each version of
|
// This loop will terminate because it will call enqueue on each version of
|
||||||
// each dependency of the modules in hasDepsInAll at most once (and only
|
// each dependency of the modules in hasDepsInAll at most once (and only
|
||||||
|
@ -406,11 +405,11 @@ func readModGraph(ctx context.Context, pruning modPruning, roots []module.Versio
|
||||||
needsEnqueueing := map[module.Version]bool{}
|
needsEnqueueing := map[module.Version]bool{}
|
||||||
for p := range hasDepsInAll {
|
for p := range hasDepsInAll {
|
||||||
m := module.Version{Path: p, Version: mg.g.Selected(p)}
|
m := module.Version{Path: p, Version: mg.g.Selected(p)}
|
||||||
reqs, ok := mg.g.RequiredBy(m)
|
if !seen[m] {
|
||||||
if !ok {
|
|
||||||
needsEnqueueing[m] = true
|
needsEnqueueing[m] = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
reqs, _ := mg.g.RequiredBy(m)
|
||||||
for _, r := range reqs {
|
for _, r := range reqs {
|
||||||
s := module.Version{Path: r.Path, Version: mg.g.Selected(r.Path)}
|
s := module.Version{Path: r.Path, Version: mg.g.Selected(r.Path)}
|
||||||
if cmpVersion(s.Version, r.Version) > 0 && !seen[s] {
|
if cmpVersion(s.Version, r.Version) > 0 && !seen[s] {
|
||||||
|
|
59
src/cmd/go/testdata/script/work_goproxy_off.txt
vendored
Normal file
59
src/cmd/go/testdata/script/work_goproxy_off.txt
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
go work init
|
||||||
|
go work use . ./sub
|
||||||
|
|
||||||
|
# Verify that the go.mod files for both modules in the workspace are tidy,
|
||||||
|
# and add missing go.sum entries as needed.
|
||||||
|
|
||||||
|
cp go.mod go.mod.orig
|
||||||
|
go mod tidy
|
||||||
|
cmp go.mod go.mod.orig
|
||||||
|
|
||||||
|
cd sub
|
||||||
|
cp go.mod go.mod.orig
|
||||||
|
go mod tidy
|
||||||
|
cmp go.mod go.mod.orig
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
go list -m all
|
||||||
|
stdout '^rsc\.io/quote v1\.5\.1$'
|
||||||
|
stdout '^rsc\.io/sampler v1\.3\.1$'
|
||||||
|
|
||||||
|
# Now remove the module dependencies from the module cache.
|
||||||
|
# Because one module upgrades a transitive dependency needed by another,
|
||||||
|
# listing the modules in the workspace should error out.
|
||||||
|
|
||||||
|
go clean -modcache
|
||||||
|
env GOPROXY=off
|
||||||
|
! go list -m all
|
||||||
|
stderr '^go: rsc.io/sampler@v1.3.0: module lookup disabled by GOPROXY=off$'
|
||||||
|
|
||||||
|
-- example.go --
|
||||||
|
package example
|
||||||
|
|
||||||
|
import _ "rsc.io/sampler"
|
||||||
|
-- go.mod --
|
||||||
|
module example
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require rsc.io/sampler v1.3.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
|
||||||
|
rsc.io/testonly v1.0.0 // indirect
|
||||||
|
)
|
||||||
|
-- sub/go.mod --
|
||||||
|
module example/sub
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require rsc.io/quote v1.5.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
|
||||||
|
rsc.io/sampler v1.3.1 // indirect
|
||||||
|
)
|
||||||
|
-- sub/sub.go --
|
||||||
|
package example
|
||||||
|
|
||||||
|
import _ "rsc.io/quote"
|
Loading…
Reference in a new issue