]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: update vendored golang.org/x/mod
authorDmitri Shuralyov <dmitshur@golang.org>
Fri, 12 May 2023 12:55:49 +0000 (08:55 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 17 May 2023 17:26:48 +0000 (17:26 +0000)
Pull in CL 492990. This teaches 'go mod tidy' and other go subcommands
that write go.mod files to use semantic sort for exclude blocks, gated
on said files declaring Go version 1.21 or higher.

go get golang.org/x/mod@e7bea8f1d64f  # includes CL 492990
go mod tidy
go mod vendor

Fixes #60028.

Change-Id: Ia9342dcc23cd68de068a70657b59c25f69afa381
Reviewed-on: https://go-review.googlesource.com/c/go/+/494578
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

src/cmd/go.mod
src/cmd/go.sum
src/cmd/go/testdata/script/mod_exclude_go121.txt [new file with mode: 0644]
src/cmd/vendor/golang.org/x/mod/modfile/rule.go
src/cmd/vendor/modules.txt

index 529fc402dd9a158b1a1b189b652f6adc03421804..746d4428f91931d2561a343eec29bcffaa2ebee4 100644 (file)
@@ -5,7 +5,7 @@ go 1.21
 require (
        github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26
        golang.org/x/arch v0.2.1-0.20230208145055-40c19ba4a7c5
-       golang.org/x/mod v0.10.0
+       golang.org/x/mod v0.10.1-0.20230517154618-e7bea8f1d64f
        golang.org/x/sync v0.2.0
        golang.org/x/sys v0.8.0
        golang.org/x/term v0.5.0
index d964d568e4f3bb342bb73d8b7b8f40195abb1a7f..db69eb030034eafe9802ddfa4d579dafe42966a7 100644 (file)
@@ -4,8 +4,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2 h1:rcanfLh
 github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
 golang.org/x/arch v0.2.1-0.20230208145055-40c19ba4a7c5 h1:UFbINK7+lzLJEIqCXPlzx05ivYhLQeXCkxW3SSH3f8Q=
 golang.org/x/arch v0.2.1-0.20230208145055-40c19ba4a7c5/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
-golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
-golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.10.1-0.20230517154618-e7bea8f1d64f h1:ghNt+qaUoQ453QdEj40jEN5kYz71m4aDEkk767JfeR0=
+golang.org/x/mod v0.10.1-0.20230517154618-e7bea8f1d64f/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
 golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
diff --git a/src/cmd/go/testdata/script/mod_exclude_go121.txt b/src/cmd/go/testdata/script/mod_exclude_go121.txt
new file mode 100644 (file)
index 0000000..51c8a00
--- /dev/null
@@ -0,0 +1,34 @@
+# go.dev/issue/60028: use semver sort in exclude block in 1.21
+cp $WORK/go.mod.badfmtexclude go.mod
+go mod edit -go=1.20
+cmp go.mod $WORK/go.mod.goodfmtexclude120
+go mod edit -go=1.21
+cmp go.mod $WORK/go.mod.goodfmtexclude121
+
+-- $WORK/go.mod.badfmtexclude --
+module     x.x/y/z
+exclude  (
+       x.1   v1.11.0
+       x.1    v1.10.0
+       x.1     v1.9.0
+)
+-- $WORK/go.mod.goodfmtexclude120 --
+module x.x/y/z
+
+go 1.20
+
+exclude (
+       x.1 v1.10.0
+       x.1 v1.11.0
+       x.1 v1.9.0
+)
+-- $WORK/go.mod.goodfmtexclude121 --
+module x.x/y/z
+
+go 1.21
+
+exclude (
+       x.1 v1.9.0
+       x.1 v1.10.0
+       x.1 v1.11.0
+)
index 6bcde8fabe386fe1fd4e35715b8b438ec7c7c329..c20aef1566b617ab002126d68a5bb4336d86e350 100644 (file)
@@ -1387,13 +1387,21 @@ func (f *File) DropRetract(vi VersionInterval) error {
 func (f *File) SortBlocks() {
        f.removeDups() // otherwise sorting is unsafe
 
+       // semanticSortForExcludeVersionV is the Go version (plus leading "v") at which
+       // lines in exclude blocks start to use semantic sort instead of lexicographic sort.
+       // See go.dev/issue/60028.
+       const semanticSortForExcludeVersionV = "v1.21"
+       useSemanticSortForExclude := f.Go != nil && semver.Compare("v"+f.Go.Version, semanticSortForExcludeVersionV) >= 0
+
        for _, stmt := range f.Syntax.Stmt {
                block, ok := stmt.(*LineBlock)
                if !ok {
                        continue
                }
                less := lineLess
-               if block.Token[0] == "retract" {
+               if block.Token[0] == "exclude" && useSemanticSortForExclude {
+                       less = lineExcludeLess
+               } else if block.Token[0] == "retract" {
                        less = lineRetractLess
                }
                sort.SliceStable(block.Line, func(i, j int) bool {
@@ -1496,6 +1504,22 @@ func lineLess(li, lj *Line) bool {
        return len(li.Token) < len(lj.Token)
 }
 
+// lineExcludeLess reports whether li should be sorted before lj for lines in
+// an "exclude" block.
+func lineExcludeLess(li, lj *Line) bool {
+       if len(li.Token) != 2 || len(lj.Token) != 2 {
+               // Not a known exclude specification.
+               // Fall back to sorting lexicographically.
+               return lineLess(li, lj)
+       }
+       // An exclude specification has two tokens: ModulePath and Version.
+       // Compare module path by string order and version by semver rules.
+       if pi, pj := li.Token[0], lj.Token[0]; pi != pj {
+               return pi < pj
+       }
+       return semver.Compare(li.Token[1], lj.Token[1]) < 0
+}
+
 // lineRetractLess returns whether li should be sorted before lj for lines in
 // a "retract" block. It treats each line as a version interval. Single versions
 // are compared as if they were intervals with the same low and high version.
index 2cf140f093444a0147b3b7d17710a82c383f4670..40e45bba5ff7445a1a47871e03791976997adc9a 100644 (file)
@@ -23,7 +23,7 @@ golang.org/x/arch/arm/armasm
 golang.org/x/arch/arm64/arm64asm
 golang.org/x/arch/ppc64/ppc64asm
 golang.org/x/arch/x86/x86asm
-# golang.org/x/mod v0.10.0
+# golang.org/x/mod v0.10.1-0.20230517154618-e7bea8f1d64f
 ## explicit; go 1.17
 golang.org/x/mod/internal/lazyregexp
 golang.org/x/mod/modfile