]> Cypherpunks repositories - gostls13.git/commit
cmd/go: avoid accidental downgrades in 'go get' with latest and patch
authorJay Conrod <jayconrod@google.com>
Fri, 31 May 2019 22:56:28 +0000 (18:56 -0400)
committerJay Conrod <jayconrod@google.com>
Fri, 14 Jun 2019 18:01:34 +0000 (18:01 +0000)
commit4c2ffd26ec3fe2fb9552b5a38c2b731e86a85abf
tree717c4be2f345ecd5614499e284afe758cdf900ce
parent80f89133ea54b96d491f8780daaac253ed09abe9
cmd/go: avoid accidental downgrades in 'go get' with latest and patch

Currently, 'go get -u' and 'go get -u=patch' avoid accidentally
downgrading modules by preventing upgrades in two cases:

1) If the current version is a prerelease that is semantically later
   than the "latest" or "patch" version.
2) If the current version is a pseudoversion that is chronologically
   newer than the "latest" or "patch" version.

With this change, 'go get m@latest' and 'go get m@patch' prevent
downgrades using the same checks.

Also: 'go get m@patch' now works if m is a module path but not a
package path (i.e., there is no package in the module root directory).

Fixes #30634
Fixes #32537

Change-Id: I916630c385b5f3ba7c13e0d65ba08f73a1a67829
Reviewed-on: https://go-review.googlesource.com/c/go/+/180337
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
16 files changed:
src/cmd/go/alldocs.go
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/list.go
src/cmd/go/internal/modload/query.go
src/cmd/go/internal/modload/query_test.go
src/cmd/go/internal/mvs/mvs.go
src/cmd/go/testdata/mod/example.com_noroot_v1.0.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_noroot_v1.0.1.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_pseudoupgrade_v0.0.0-20190430073000-30950c05d534.txt [moved from src/cmd/go/testdata/mod/example.com_pseudoupgrade_v0.0.0-20190429073000-30950c05d534.txt with 57% similarity]
src/cmd/go/testdata/script/mod_get_pseudo.txt
src/cmd/go/testdata/script/mod_get_upgrade_pseudo.txt
src/cmd/go/testdata/script/mod_list_upgrade_pseudo.txt
src/cmd/go/testdata/script/mod_load_badchain.txt
src/cmd/go/testdata/script/mod_upgrade_patch.txt