mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +00:00
cmd/go: sort vendor/modules.txt package lists
Right now they are in a deterministic order but one that depends on the shape of the import graph. Sort them instead. Change-Id: Ia0c076a0d6677a511e52acf01f38353e9895dec2 Reviewed-on: https://go-review.googlesource.com/c/go/+/174527 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
3259bc4419
commit
40a6d0e0ef
@ -11,6 +11,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"cmd/go/internal/base"
|
"cmd/go/internal/base"
|
||||||
@ -72,6 +73,7 @@ func runVendor(cmd *base.Command, args []string) {
|
|||||||
if cfg.BuildV {
|
if cfg.BuildV {
|
||||||
fmt.Fprintf(os.Stderr, "# %s %s%s\n", m.Path, m.Version, repl)
|
fmt.Fprintf(os.Stderr, "# %s %s%s\n", m.Path, m.Version, repl)
|
||||||
}
|
}
|
||||||
|
sort.Strings(pkgs)
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
fmt.Fprintf(&buf, "%s\n", pkg)
|
fmt.Fprintf(&buf, "%s\n", pkg)
|
||||||
if cfg.BuildV {
|
if cfg.BuildV {
|
||||||
|
3
src/cmd/go/testdata/script/mod_vendor.txt
vendored
3
src/cmd/go/testdata/script/mod_vendor.txt
vendored
@ -18,6 +18,7 @@ stderr '^y'
|
|||||||
stderr '^# z v1.0.0 => ./z'
|
stderr '^# z v1.0.0 => ./z'
|
||||||
stderr '^z'
|
stderr '^z'
|
||||||
! stderr '^w'
|
! stderr '^w'
|
||||||
|
grep 'a/foo/bar/b\na/foo/bar/c' vendor/modules.txt # must be sorted
|
||||||
|
|
||||||
go list -f {{.Dir}} x
|
go list -f {{.Dir}} x
|
||||||
stdout 'src[\\/]x'
|
stdout 'src[\\/]x'
|
||||||
@ -126,6 +127,7 @@ func TestDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
-- a/foo/bar/c/main.go --
|
-- a/foo/bar/c/main.go --
|
||||||
package c
|
package c
|
||||||
|
import _ "a/foo/bar/b"
|
||||||
-- a/foo/bar/c/main_test.go --
|
-- a/foo/bar/c/main_test.go --
|
||||||
package c
|
package c
|
||||||
|
|
||||||
@ -190,7 +192,6 @@ import _ "a"
|
|||||||
-- testdata2.go --
|
-- testdata2.go --
|
||||||
package m
|
package m
|
||||||
|
|
||||||
import _ "a/foo/bar/b"
|
|
||||||
import _ "a/foo/bar/c"
|
import _ "a/foo/bar/c"
|
||||||
-- v1.go --
|
-- v1.go --
|
||||||
package m
|
package m
|
||||||
|
Loading…
x
Reference in New Issue
Block a user