]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modcmd: in 'go mod tidy', suspend go.mod writes until tidy
authorBryan C. Mills <bcmills@google.com>
Fri, 12 Mar 2021 16:26:51 +0000 (11:26 -0500)
committerBryan C. Mills <bcmills@google.com>
Tue, 16 Mar 2021 13:06:04 +0000 (13:06 +0000)
For #36460

Change-Id: Ia8633f37aec8c7ed532bf7278867251e5e2a4285
Reviewed-on: https://go-review.googlesource.com/c/go/+/301370
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/modcmd/tidy.go

index 34ff86ff18548d8a0ed35ab6816a67f39e8f6406..33ecd80bcb50702d9121c09a912d92213101e191 100644 (file)
@@ -60,6 +60,7 @@ func runTidy(ctx context.Context, cmd *base.Command, args []string) {
        // request that their test dependencies be included.
        modload.ForceUseModules = true
        modload.RootMode = modload.NeedRoot
+       modload.DisallowWriteGoMod() // Suppress writing until we've tidied the file.
 
        modload.LoadPackages(ctx, modload.PackageOpts{
                Tags:                     imports.AnyTags(),
@@ -72,5 +73,7 @@ func runTidy(ctx context.Context, cmd *base.Command, args []string) {
 
        modload.TidyBuildList()
        modload.TrimGoSum()
+
+       modload.AllowWriteGoMod()
        modload.WriteGoMod()
 }