Skip to content

Commit

Permalink
Revert "cmd/go: add a Latest field to the output of 'go mod download …
Browse files Browse the repository at this point in the history
…-json'"

This reverts CL 183841.

Fixes #34533

Reason for revert: Introduced a significant performance regression for repos with many incompatible-version tags.

Change-Id: I75d7fd76e6e1a0902b114b00167b38439e0f8221
Reviewed-on: https://go-review.googlesource.com/c/go/+/198699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
  • Loading branch information
Bryan C. Mills committed Oct 4, 2019
1 parent 0471417 commit 961837d
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 74 deletions.
1 change: 0 additions & 1 deletion src/cmd/go/alldocs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions src/cmd/go/internal/modcmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ corresponding to this Go struct:
Dir string // absolute path to cached source root directory
Sum string // checksum for path, version (as in go.sum)
GoModSum string // checksum for go.mod (as in go.sum)
Latest bool // would @latest resolve to this version?
}
See 'go help modules' for more about module queries.
Expand All @@ -66,7 +65,6 @@ type moduleJSON struct {
Dir string `json:",omitempty"`
Sum string `json:",omitempty"`
GoModSum string `json:",omitempty"`
Latest bool `json:",omitempty"`
}

func runDownload(cmd *base.Command, args []string) {
Expand Down Expand Up @@ -105,31 +103,6 @@ func runDownload(cmd *base.Command, args []string) {
work.Add(m)
}

latest := map[string]string{} // path → version
if *downloadJSON {
// We need to populate the Latest field, but if the main module depends on a
// version newer than latest — or if the version requested on the command
// line is itself newer than latest — that's not trivial to determine from
// the info returned by ListModules. Instead, we issue a separate
// ListModules request for "latest", which should be inexpensive relative to
// downloading the modules.
var latestArgs []string
for _, m := range mods {
if m.Error != "" {
continue
}
latestArgs = append(latestArgs, m.Path+"@latest")
}

if len(latestArgs) > 0 {
for _, info := range modload.ListModules(latestArgs, listU, listVersions) {
if info.Version != "" {
latest[info.Path] = info.Version
}
}
}
}

work.Do(10, func(item interface{}) {
m := item.(*moduleJSON)
var err error
Expand Down Expand Up @@ -160,9 +133,6 @@ func runDownload(cmd *base.Command, args []string) {
m.Error = err.Error()
return
}
if latest[m.Path] == m.Version {
m.Latest = true
}
})

if *downloadJSON {
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/go/testdata/script/mod_download.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ stderr 'this.domain.is.invalid'
stdout '"Error": ".*this.domain.is.invalid.*"'

# download -json with version should print JSON
# and download the .info file for the 'latest' version.
go mod download -json 'rsc.io/quote@<=v1.5.0'
stdout '^\t"Path": "rsc.io/quote"'
stdout '^\t"Version": "v1.5.0"'
Expand All @@ -28,14 +27,13 @@ stdout '^\t"Sum": "h1:6fJa6E\+wGadANKkUMlZ0DhXFpoKlslOQDCo259XtdIE="' # hash of
stdout '^\t"GoModSum": "h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe\+TKr0="'
! stdout '"Error"'

exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info

# download queries above should not have added to go.mod.
go list -m all
! stdout rsc.io

# add to go.mod so we can test non-query downloads
go mod edit -require rsc.io/quote@v1.5.2
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip

Expand Down
20 changes: 0 additions & 20 deletions src/cmd/go/testdata/script/mod_download_latest.txt

This file was deleted.

20 changes: 0 additions & 20 deletions src/cmd/go/testdata/script/mod_list_upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
env GO111MODULE=on

# If the current version is not latest, 'go list -u' should include its upgrade.
go list -m -u all
stdout 'rsc.io/quote v1.2.0 \[v1\.5\.2\]'

# If the current version is latest, 'go list -u' should omit the upgrade.
go get -d rsc.io/quote@v1.5.2
go list -m -u all
stdout 'rsc.io/quote v1.5.2$'

# If the current version is newer than latest, 'go list -u' should
# omit the upgrade.
go get -d rsc.io/quote@v1.5.3-pre1
go list -m -u all
stdout 'rsc.io/quote v1.5.3-pre1$'

# If the current build list has a higher version and the user asks about
# a lower one, -u should report the upgrade for the lower one
# but leave the build list unchanged.
go list -m -u rsc.io/quote@v1.5.1
stdout 'rsc.io/quote v1.5.1 \[v1.5.2\]$'
go list -m -u rsc.io/quote
stdout 'rsc.io/quote v1.5.3-pre1$'

-- go.mod --
module x
require rsc.io/quote v1.2.0

0 comments on commit 961837d

Please sign in to comment.