-
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.
[release-branch.go1.16] cmd/go: error out of 'go mod tidy' if the go …
…version is newer than supported This backports the test from CL 319669, but — because of extensive changes to the module loader during the Go 1.17 cycle — the implementation is entirely different. (This implementation is based on the addGoStmt function present in init.go in the 1.16 branch.) Fixes #46144 Updates #46142 Change-Id: Ib7a0a159e53cbe476be6aa9a050add10cc750dec Reviewed-on: https://go-review.googlesource.com/c/go/+/319671 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
- Loading branch information
1 parent
c9f27b8
commit f2222d8
Showing
3 changed files
with
80 additions
and
0 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,48 @@ | ||
# https://golang.org/issue/46142: 'go mod tidy' should error out if the version | ||
# in the go.mod file is newer than the most recent supported version. | ||
|
||
cp go.mod go.mod.orig | ||
|
||
|
||
# If the go.mod file specifies an unsupported Go version, 'go mod tidy' should | ||
# refuse to edit it: we don't know what a tidy go.mod file for that version | ||
# would look like. | ||
|
||
! go mod tidy | ||
stderr 'go mod tidy: go.mod file indicates go 2000.0, but maximum supported version is '$goversion'$' | ||
cmp go.mod go.mod.orig | ||
|
||
|
||
# The -e flag should push past the error and edit the file anyway, | ||
# but preserve the too-high version. | ||
|
||
cp go.mod.orig go.mod | ||
go mod tidy -e | ||
stderr 'go mod tidy: go.mod file indicates go 2000.0, but maximum supported version is '$goversion'$' | ||
cmp go.mod go.mod.tidy | ||
|
||
|
||
-- go.mod -- | ||
module example.net/from/the/future | ||
|
||
go 2000.0 | ||
|
||
replace example.net/m v0.0.0 => ./m | ||
-- go.mod.tidy -- | ||
module example.net/from/the/future | ||
|
||
go 2000.0 | ||
|
||
replace example.net/m v0.0.0 => ./m | ||
|
||
require example.net/m v0.0.0 | ||
-- x.go -- | ||
package x | ||
|
||
import "example.net/m" | ||
-- m/go.mod -- | ||
module example.net/m | ||
|
||
go 1.17 | ||
-- m/m.go -- | ||
package m |