]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: sort vendor/modules.txt package lists
authorRuss Cox <rsc@golang.org>
Tue, 30 Apr 2019 20:18:53 +0000 (16:18 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 1 May 2019 18:50:36 +0000 (18:50 +0000)
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>

src/cmd/go/internal/modcmd/vendor.go
src/cmd/go/testdata/script/mod_vendor.txt

index 7265e62a2f4a7b0d0b2b128a0240977c7dd19695..44cabd5dea41ba935c171742a58f123ffc4fc33b 100644 (file)
@@ -11,6 +11,7 @@ import (
        "io/ioutil"
        "os"
        "path/filepath"
+       "sort"
        "strings"
 
        "cmd/go/internal/base"
@@ -72,6 +73,7 @@ func runVendor(cmd *base.Command, args []string) {
                        if cfg.BuildV {
                                fmt.Fprintf(os.Stderr, "# %s %s%s\n", m.Path, m.Version, repl)
                        }
+                       sort.Strings(pkgs)
                        for _, pkg := range pkgs {
                                fmt.Fprintf(&buf, "%s\n", pkg)
                                if cfg.BuildV {
index 25a77a3670c5ce6218e3bcd666fa6e45b44f621e..eae4f2946ce5318214f581fa0d57939964e04d3a 100644 (file)
@@ -18,6 +18,7 @@ stderr '^y'
 stderr '^# z v1.0.0 => ./z'
 stderr '^z'
 ! stderr '^w'
+grep 'a/foo/bar/b\na/foo/bar/c' vendor/modules.txt # must be sorted
 
 go list -f {{.Dir}} x
 stdout 'src[\\/]x'
@@ -126,6 +127,7 @@ func TestDir(t *testing.T) {
 }
 -- a/foo/bar/c/main.go --
 package c
+import _ "a/foo/bar/b"
 -- a/foo/bar/c/main_test.go --
 package c
 
@@ -190,7 +192,6 @@ import _ "a"
 -- testdata2.go --
 package m
 
-import _ "a/foo/bar/b"
 import _ "a/foo/bar/c"
 -- v1.go --
 package m