-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: disallow go.sum updates in -mod=readonly
When running go build with the flag -mod=readonly, it fails the build if go.sum files requires updating. This ensures that CI/CD systems get a complete go.sum file so that they'd never hit a notary, assuming the CI/CD system passes the above flag. I am not familiar with the entire codebase but I assume goSum.dirty will always be true if go.sum has any missing lines. Fixes #30667 Change-Id: I767d3b594055d8c10048f4c68e6687c94bb0545c Reviewed-on: https://go-review.googlesource.com/c/go/+/166237 Reviewed-by: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
- Loading branch information
1 parent
19966e9
commit d21c7b7
Showing
4 changed files
with
46 additions
and
4 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
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,29 @@ | ||
# Test that go.sum does not get updated when -mod=readonly flag is set | ||
env GO111MODULE=on | ||
|
||
go get rsc.io/quote | ||
go mod tidy | ||
|
||
# go.sum != dirty; -mod=readonly | ||
go build -mod=readonly | ||
|
||
# dirty up go.sum by removing it. | ||
rm go.sum | ||
|
||
# go.sum == dirty; -mod=readonly | ||
! go build -mod=readonly | ||
|
||
stderr 'go: updates to go.sum needed, disabled by -mod=readonly' | ||
|
||
-- go.mod -- | ||
module m | ||
|
||
-- main.go -- | ||
|
||
package main | ||
|
||
import "rsc.io/quote" | ||
|
||
func main() { | ||
println(quote.Hello()) | ||
} |