]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix 'go get vanity/repo/...' in clean GOPATH
authorRuss Cox <rsc@golang.org>
Fri, 26 Sep 2014 16:09:27 +0000 (12:09 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 26 Sep 2014 16:09:27 +0000 (12:09 -0400)
The pattern was only working if the checkout had
already been done, but the code was trying to make
it work even the first time. Test and fix.

Fixes #8335.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/146310043

src/cmd/go/test.bash
src/cmd/go/vcs.go

index 8bd01ea21b0cdcaafd23970ceba267f350e02f34..5e4e43722a15a393c284f79504ba5fb31132e579 100755 (executable)
@@ -948,6 +948,18 @@ elif ! grep "$GOARCH test3.go p xyzp/test3.go/123" testdata/std.out > /dev/null;
        ok=false
 fi
 
+TEST go get works with vanity wildcards
+d=$(mktemp -d -t testgoXXX)
+export GOPATH=$d
+if ! ./testgo get -u rsc.io/pdf/...; then
+       ok=false
+elif [ ! -x $d/bin/pdfpasswd ]; then
+       echo did not build rsc.io/pdf/pdfpasswd
+       ok=false
+fi
+unset GOPATH
+rm -rf $d
+
 # clean up
 if $started; then stop; fi
 rm -rf testdata/bin testdata/bin1
index d07948e64c433fb5691268911da9f47a1194bd68..c5d246835d749365bc3182702127d2baa49120c1 100644 (file)
@@ -361,7 +361,14 @@ var httpPrefixRE = regexp.MustCompile(`^https?:`)
 func repoRootForImportPath(importPath string) (*repoRoot, error) {
        rr, err := repoRootForImportPathStatic(importPath, "")
        if err == errUnknownSite {
-               rr, err = repoRootForImportDynamic(importPath)
+               // If there are wildcards, look up the thing before the wildcard,
+               // hoping it applies to the wildcarded parts too.
+               // This makes 'go get rsc.io/pdf/...' work in a fresh GOPATH.
+               lookup := strings.TrimSuffix(importPath, "/...")
+               if i := strings.Index(lookup, "/.../"); i >= 0 {
+                       lookup = lookup[:i]
+               }
+               rr, err = repoRootForImportDynamic(lookup)
 
                // repoRootForImportDynamic returns error detail
                // that is irrelevant if the user didn't intend to use a