aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/query.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2020-05-01 15:30:58 -0400
committerJay Conrod <jayconrod@google.com>2020-05-04 16:50:30 +0000
commit1dcbd8dc58abf7319a8f557536e3b5158cba8ed7 (patch)
tree395d203c4a0be27908d4680909c4724f99e45f65 /src/cmd/go/internal/modload/query.go
parentb3c0fe1d14485d34acc402f795eff32b36d6c4e2 (diff)
downloadgo-1dcbd8dc58abf7319a8f557536e3b5158cba8ed7.tar.gz
go-1dcbd8dc58abf7319a8f557536e3b5158cba8ed7.zip
cmd/go/internal/modload: make QueryPattern consider current versions
QueryPattern will now look up the current version of a module (if any) before invoking queryProxy. This changes the interpretation of some patterns (like "upgrade") and avoids the need to download earlier versions for earlier versions when the current version is +incompatible. Fixes #37574 Change-Id: I4089d6099236493df13a7f88a252b5e5e556d383 Reviewed-on: https://go-review.googlesource.com/c/go/+/231599 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/query.go')
-rw-r--r--src/cmd/go/internal/modload/query.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go
index f8ea7e6309..5e9cfdcfe3 100644
--- a/src/cmd/go/internal/modload/query.go
+++ b/src/cmd/go/internal/modload/query.go
@@ -455,8 +455,9 @@ func QueryPattern(pattern, query string, allowed func(module.Version) bool) ([]Q
err := modfetch.TryProxies(func(proxy string) error {
queryModule := func(path string) (r QueryResult, err error) {
+ current := findCurrentVersion(path)
r.Mod.Path = path
- r.Rev, err = queryProxy(proxy, path, query, "", allowed)
+ r.Rev, err = queryProxy(proxy, path, query, current, allowed)
if err != nil {
return r, err
}
@@ -508,6 +509,15 @@ func modulePrefixesExcludingTarget(path string) []string {
return prefixes
}
+func findCurrentVersion(path string) string {
+ for _, m := range buildList {
+ if m.Path == path {
+ return m.Version
+ }
+ }
+ return ""
+}
+
type prefixResult struct {
QueryResult
err error