]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: fix truncated error message from goModDirtyError
authorBryan C. Mills <bcmills@google.com>
Wed, 14 Apr 2021 14:16:51 +0000 (10:16 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 14 Apr 2021 15:02:11 +0000 (15:02 +0000)
The 'go mod tidy' hint was truncated due to a typo in CL 293689,
and that particular case was not covered by any existing test.

Updates #36460
Updates #40775

Change-Id: Ib6fa872a9dfdafc4e9a112e8add2ff5aecd2dbd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310089
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/mod_require_exclude.txt

index 777b63841fdf01a3a8609f2062709d8ce5d25400..120afef4ff4f12c8a91444d772712e172a79c19b 100644 (file)
@@ -354,7 +354,7 @@ func (goModDirtyError) Error() string {
                return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%v; to update it:\n\tgo mod tidy", cfg.BuildMod)
        }
        if cfg.BuildModReason != "" {
-               return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%s\n\t(%s)\n\tto update it:\n\t", cfg.BuildMod, cfg.BuildModReason)
+               return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%s\n\t(%s)\n\tto update it:\n\tgo mod tidy", cfg.BuildMod, cfg.BuildModReason)
        }
        return "updates to go.mod needed; to update it:\n\tgo mod tidy"
 }
index 5b6143da42f0704023df4fc4719b2df4262ca84f..0946dbf0bb39d0796b3f66c8d593c037c5ef51b9 100644 (file)
@@ -17,6 +17,17 @@ stderr '^go: updates to go.mod needed, disabled by -mod=vendor; to update it:\n\
 ! stdout '^rsc.io/sampler v1.99.99'
 cmp go.mod go.mod.orig
 
+# The failure message should be clear when -mod=vendor is implicit.
+
+go mod edit -go=1.14
+! go list -m rsc.io/sampler
+stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
+stderr '^go: updates to go.mod needed, disabled by -mod=vendor\n\t\(Go version in go.mod is at least 1.14 and vendor directory exists\.\)\n\tto update it:\n\tgo mod tidy$'
+! stdout '^rsc.io/sampler v1.99.99'
+go mod edit -go=1.13
+cmp go.mod go.mod.orig
+
+
 # With the selected version excluded, commands that load only modules should
 # drop the excluded module.
 
@@ -58,7 +69,11 @@ module x
 go 1.13
 
 exclude rsc.io/sampler v1.99.99
+
 require rsc.io/sampler v1.99.99
+-- vendor/modules.txt --
+# rsc.io/sampler v1.99.99
+## explicit
 -- go.moddrop --
 module x