]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfetch: stop migrating go.modverify to go.sum
authorJay Conrod <jayconrod@google.com>
Mon, 29 Jun 2020 20:28:18 +0000 (16:28 -0400)
committerJay Conrod <jayconrod@google.com>
Fri, 14 Aug 2020 21:04:00 +0000 (21:04 +0000)
go.modverify was renamed to go.sum before vgo was merged into
cmd/go. It's been long enough that we can safely drop support for it.

For #25525

Change-Id: If8da66280a0fb6a4d4db0b170700775523c18571
Reviewed-on: https://go-review.googlesource.com/c/go/+/240458
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/testdata/script/mod_verify.txt

index fd7a5cef831cd2b7e41e8a5c5d458589e38f2aac..8df2289097be7eefc87e0a3882532e3d02632dd8 100644 (file)
@@ -374,12 +374,11 @@ type modSum struct {
 
 var goSum struct {
        mu        sync.Mutex
-       m         map[module.Version][]string // content of go.sum file (+ go.modverify if present)
+       m         map[module.Version][]string // content of go.sum file
        checked   map[modSum]bool             // sums actually checked during execution
        dirty     bool                        // whether we added any new sums to m
        overwrite bool                        // if true, overwrite go.sum without incorporating its contents
        enabled   bool                        // whether to use go.sum at all
-       modverify string                      // path to go.modverify, to be deleted
 }
 
 // initGoSum initializes the go.sum data.
@@ -403,19 +402,6 @@ func initGoSum() (bool, error) {
        goSum.enabled = true
        readGoSum(goSum.m, GoSumFile, data)
 
-       // Add old go.modverify file.
-       // We'll delete go.modverify in WriteGoSum.
-       alt := strings.TrimSuffix(GoSumFile, ".sum") + ".modverify"
-       if data, err := renameio.ReadFile(alt); err == nil {
-               migrate := make(map[module.Version][]string)
-               readGoSum(migrate, alt, data)
-               for mod, sums := range migrate {
-                       for _, sum := range sums {
-                               addModSumLocked(mod, sum)
-                       }
-               }
-               goSum.modverify = alt
-       }
        return true, nil
 }
 
@@ -616,14 +602,9 @@ func WriteGoSum() {
        goSum.mu.Lock()
        defer goSum.mu.Unlock()
 
-       if !goSum.enabled {
-               // If we haven't read the go.sum file yet, don't bother writing it: at best,
-               // we could rename the go.modverify file if it isn't empty, but we haven't
-               // needed to touch it so far — how important could it be?
-               return
-       }
-       if !goSum.dirty {
-               // Don't bother opening the go.sum file if we don't have anything to add.
+       if !goSum.enabled || !goSum.dirty {
+               // If we haven't read go.sum yet or if we don't have anything to add,
+               // don't bother opening it.
                return
        }
        if cfg.BuildMod == "readonly" {
@@ -674,10 +655,6 @@ func WriteGoSum() {
        goSum.checked = make(map[modSum]bool)
        goSum.dirty = false
        goSum.overwrite = false
-
-       if goSum.modverify != "" {
-               os.Remove(goSum.modverify) // best effort
-       }
 }
 
 // TrimGoSum trims go.sum to contain only the modules for which keep[m] is true.
index 646bc62bb7015b026392b480870c723bf4e96b0b..391840043565f2c9b563c4db741020cc74319fa6 100644 (file)
@@ -12,20 +12,18 @@ go mod verify
 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
 
 # With bad go.sum, sync (which must download) fails.
-# Even if the bad sum is in the old legacy go.modverify file.
 rm go.sum
-cp go.sum.bad go.modverify
+cp go.sum.bad go.sum
 ! go mod tidy
 stderr 'checksum mismatch'
 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
 
-# With good go.sum, sync works (and moves go.modverify to go.sum).
+# With good go.sum, sync works.
 rm go.sum
-cp go.sum.good go.modverify
+cp go.sum.good go.sum
 go mod tidy
 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
 exists $GOPATH/pkg/mod/rsc.io/quote@v1.1.0/quote.go
-! exists go.modverify
 
 # go.sum should have the new checksum for go.mod
 grep '^rsc.io/quote v1.1.0/go.mod ' go.sum