-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: don't panic when explaining lost upgrades due to downgrades
If a user runs 'go get mod@vers' where the module transitively requires itself at a newer version, 'go get' attempts to perform a downgrade, which necessarily excludes the requested version of the module. Previously, we called mvs.BuildList with the requested module version as the target. This panicked because BuildList doesn't allow the target module (typically the main module) to require a newer version of itself. With this change, when we lose an upgrade due to a downgrade, we call mvs.BuildList through a wrapper that treats the lost module version as requirement of a synthetic root module, rather than the target module. This avoids the panic. This change also starts reporting errors when an upgraded module is lost entirely (downgrades caused the module to be completely removed from the build list). Fixes #31491 Change-Id: I70ca261c20af7553cad2d3b840a1eaf3d18a4191 Reviewed-on: https://go-review.googlesource.com/c/go/+/177602 Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
- Loading branch information
Jay Conrod
committed
May 16, 2019
1 parent
4e7bef8
commit 97ecc43
Showing
6 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
example.com/newcycle/a v1.0.0 | ||
|
||
Transitively requires v1.0.1 of itself via example.com/newcycle/b | ||
|
||
-- .mod -- | ||
module example.com/newcycle/a | ||
|
||
require example.com/newcycle/b v1.0.0 | ||
-- .info -- | ||
{"Version":"v1.0.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
example.com/newcycle/a v1.0.1 | ||
|
||
Transitively requires itself via example.com/newcycle/b | ||
|
||
-- .mod -- | ||
module example.com/newcycle/a | ||
|
||
require example.com/newcycle/b v1.0.0 | ||
-- .info -- | ||
{"Version":"v1.0.1"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
example.com/newcycle/b v1.0.0 | ||
|
||
-- .mod -- | ||
module example.com/newcycle/b | ||
|
||
require example.com/newcycle/a v1.0.1 | ||
-- .info -- | ||
{"Version":"v1.0.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
env GO111MODULE=on | ||
|
||
# Download modules to avoid stderr chatter | ||
go mod download example.com/newcycle/a@v1.0.0 | ||
go mod download example.com/newcycle/a@v1.0.1 | ||
go mod download example.com/newcycle/b@v1.0.0 | ||
|
||
go mod init m | ||
! go get example.com/newcycle/a@v1.0.0 | ||
cmp stderr stderr-expected | ||
|
||
-- stderr-expected -- | ||
go get: inconsistent versions: | ||
example.com/newcycle/a@v1.0.0 requires example.com/newcycle/a@v1.0.1 (not example.com/newcycle/a@v1.0.0) |