diff options
author | Bryan C. Mills <bcmills@google.com> | 2018-12-11 21:03:11 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2018-12-12 21:19:54 +0000 |
commit | cc8ae42a12cbbd7c7de0c1195d413fed5d9c4bbc (patch) | |
tree | a2514786f9aedb3dcfbc963ecf2c9cc5c7995a6f /src/cmd/go/internal/modcmd/tidy.go | |
parent | 05bbec7357a22e2ddd238c2f8741f0f4c779eb80 (diff) | |
download | go-cc8ae42a12cbbd7c7de0c1195d413fed5d9c4bbc.tar.gz go-cc8ae42a12cbbd7c7de0c1195d413fed5d9c4bbc.zip |
cmd/go: retain sums for replacement modules in 'go mod tidy'
Fixes #27868
Change-Id: I6c2d221c4325a2f44625e797a82735d812ee0ec1
Reviewed-on: https://go-review.googlesource.com/c/153817
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modcmd/tidy.go')
-rw-r--r-- | src/cmd/go/internal/modcmd/tidy.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modcmd/tidy.go b/src/cmd/go/internal/modcmd/tidy.go index f2063a9ea6..839c92a0a0 100644 --- a/src/cmd/go/internal/modcmd/tidy.go +++ b/src/cmd/go/internal/modcmd/tidy.go @@ -77,7 +77,17 @@ func modTidyGoSum() { keep := make(map[module.Version]bool) var walk func(module.Version) walk = func(m module.Version) { - keep[m] = true + // If we build using a replacement module, keep the sum for the replacement, + // since that's the code we'll actually use during a build. + // + // TODO(golang.org/issue/29182): Perhaps we should keep both sums, and the + // sums for both sets of transitive requirements. + r := modload.Replacement(m) + if r.Path == "" { + keep[m] = true + } else { + keep[r] = true + } list, _ := reqs.Required(m) for _, r := range list { if !keep[r] { |