]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: vendor version error message changes from x/mod
authorSam Thanawalla <samthanawalla@google.com>
Fri, 2 Feb 2024 19:20:06 +0000 (19:20 +0000)
committerSam Thanawalla <samthanawalla@google.com>
Thu, 8 Feb 2024 17:50:49 +0000 (17:50 +0000)
For golang/go#61888

Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560855
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/mod/modfile/rule.go
src/cmd/vendor/golang.org/x/mod/sumdb/client.go
src/cmd/vendor/modules.txt

index 7b548c79bd180473bd83d7269517050b4d5f9ab4..0426e34e3bb75b4719a5028deee7d16ab3fe395d 100644 (file)
@@ -6,7 +6,7 @@ require (
        github.com/google/pprof v0.0.0-20230811205829-9131a7e9cc17
        golang.org/x/arch v0.7.0
        golang.org/x/build v0.0.0-20240201175143-3ee44a092755
-       golang.org/x/mod v0.14.0
+       golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3
        golang.org/x/sync v0.6.0
        golang.org/x/sys v0.16.1-0.20240110015235-f69d32aa924f
        golang.org/x/telemetry v0.0.0-20240131160148-1cb064e7d4f2
index 572492d22fc9110b0aa38d0562867885209e97f5..0f05b696f209e052633250bb1feab61c434840db 100644 (file)
@@ -10,8 +10,8 @@ golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
 golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
 golang.org/x/build v0.0.0-20240201175143-3ee44a092755 h1:irSM9p93GT4I3+Pu/grZlkwIjrXA3GfyKwlSosVbmtU=
 golang.org/x/build v0.0.0-20240201175143-3ee44a092755/go.mod h1:RHSzqFUzT4+buJlGik6WptO5NxLQiR/ewD2uz3fgWuA=
-golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
-golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3 h1:/p/VemLWiTsjHqHwME1Iu+xIu8s9fBtwBk8bU/ejA1A=
+golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
 golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.16.1-0.20240110015235-f69d32aa924f h1:GvGFYRZ5kIldzXQj3UmUiUTMe5spPODuLKQvP38A+Qc=
index 35fd1f534cf85f6921758f4cb5ad13cda8019b88..26acaa5f7c4174b29cd1b310a41c9929c314736c 100644 (file)
@@ -308,6 +308,7 @@ var laxGoVersionRE = lazyregexp.New(`^v?(([1-9][0-9]*)\.(0|[1-9][0-9]*))([^0-9].
 
 // Toolchains must be named beginning with `go1`,
 // like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted.
+// TODO(samthanawalla): Replace regex with https://pkg.go.dev/go/version#IsValid in 1.23+
 var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`)
 
 func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) {
@@ -384,7 +385,7 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
                        errorf("toolchain directive expects exactly one argument")
                        return
                } else if strict && !ToolchainRE.MatchString(args[0]) {
-                       errorf("invalid toolchain version '%s': must match format go1.23.0 or local", args[0])
+                       errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
                        return
                }
                f.Toolchain = &Toolchain{Syntax: line}
@@ -630,7 +631,7 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string,
                        errorf("go directive expects exactly one argument")
                        return
                } else if !GoVersionRE.MatchString(args[0]) {
-                       errorf("invalid go version '%s': must match format 1.23", args[0])
+                       errorf("invalid go version '%s': must match format 1.23.0", args[0])
                        return
                }
 
@@ -646,7 +647,7 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string,
                        errorf("toolchain directive expects exactly one argument")
                        return
                } else if !ToolchainRE.MatchString(args[0]) {
-                       errorf("invalid toolchain version '%s': must match format go1.23 or local", args[0])
+                       errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
                        return
                }
 
index aecdc688491821291ff38ee4444eb634b3ecd3c8..04c6e24d0e06ffc5b95f535acf6a2b5ebbbe7f64 100644 (file)
@@ -8,7 +8,6 @@ import (
        "bytes"
        "errors"
        "fmt"
-       "path"
        "strings"
        "sync"
        "sync/atomic"
@@ -193,51 +192,7 @@ func (c *Client) SetGONOSUMDB(list string) {
 var ErrGONOSUMDB = errors.New("skipped (listed in GONOSUMDB)")
 
 func (c *Client) skip(target string) bool {
-       return globsMatchPath(c.nosumdb, target)
-}
-
-// globsMatchPath reports whether any path prefix of target
-// matches one of the glob patterns (as defined by path.Match)
-// in the comma-separated globs list.
-// It ignores any empty or malformed patterns in the list.
-func globsMatchPath(globs, target string) bool {
-       for globs != "" {
-               // Extract next non-empty glob in comma-separated list.
-               var glob string
-               if i := strings.Index(globs, ","); i >= 0 {
-                       glob, globs = globs[:i], globs[i+1:]
-               } else {
-                       glob, globs = globs, ""
-               }
-               if glob == "" {
-                       continue
-               }
-
-               // A glob with N+1 path elements (N slashes) needs to be matched
-               // against the first N+1 path elements of target,
-               // which end just before the N+1'th slash.
-               n := strings.Count(glob, "/")
-               prefix := target
-               // Walk target, counting slashes, truncating at the N+1'th slash.
-               for i := 0; i < len(target); i++ {
-                       if target[i] == '/' {
-                               if n == 0 {
-                                       prefix = target[:i]
-                                       break
-                               }
-                               n--
-                       }
-               }
-               if n > 0 {
-                       // Not enough prefix elements.
-                       continue
-               }
-               matched, _ := path.Match(glob, prefix)
-               if matched {
-                       return true
-               }
-       }
-       return false
+       return module.MatchPrefixPatterns(c.nosumdb, target)
 }
 
 // Lookup returns the go.sum lines for the given module path and version.
index abafaf30ba5fb7aaa858b3daf429b8835bdf4038..74bcaeb75262ba8a66bb1feb898173b8bf07282a 100644 (file)
@@ -26,7 +26,7 @@ golang.org/x/arch/x86/x86asm
 # golang.org/x/build v0.0.0-20240201175143-3ee44a092755
 ## explicit; go 1.21
 golang.org/x/build/relnote
-# golang.org/x/mod v0.14.0
+# golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3
 ## explicit; go 1.18
 golang.org/x/mod/internal/lazyregexp
 golang.org/x/mod/modfile