From: Russ Cox Date: Fri, 21 Oct 2016 14:45:47 +0000 (-0400) Subject: cmd/go: fix test for moved package in go get -u X-Git-Tag: go1.8beta1~697 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=17ad60b8a4b92ee36f5b14c609ad1d0b5805b886;p=gostls13.git cmd/go: fix test for moved package in go get -u What matters during go get -u is not whether there is an import comment but whether we resolved the path by an HTML tag. Fixes #16471. Change-Id: I6b194a3f73a7962a0170b4d5cf51cfed74e02c00 Reviewed-on: https://go-review.googlesource.com/31658 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Quentin Smith --- diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go index 4f7562b43d..d5e2aab0eb 100644 --- a/src/cmd/go/get.go +++ b/src/cmd/go/get.go @@ -388,7 +388,7 @@ func downloadPackage(p *Package) error { repo = resolved } } - if remote != repo && p.ImportComment != "" { + if remote != repo && rr.isCustom { return fmt.Errorf("%s is a custom import path for %s, but %s is checked out from %s", rr.root, repo, dir, remote) } } diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 2f883c94df..33fc462339 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1180,6 +1180,23 @@ func TestIssue10952(t *testing.T) { tg.run("get", "-d", "-u", importPath) } +func TestIssue16471(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + if _, err := exec.LookPath("git"); err != nil { + t.Skip("skipping because git binary not found") + } + + tg := testgo(t) + defer tg.cleanup() + tg.parallel() + tg.tempDir("src") + tg.setenv("GOPATH", tg.path(".")) + tg.must(os.MkdirAll(tg.path("src/rsc.io/go-get-issue-10952"), 0755)) + tg.runGit(tg.path("src/rsc.io"), "clone", "https://github.com/zombiezen/go-get-issue-10952") + tg.runFail("get", "-u", "rsc.io/go-get-issue-10952") + tg.grepStderr("rsc.io/go-get-issue-10952 is a custom import path for https://github.com/rsc/go-get-issue-10952, but .* is checked out from https://github.com/zombiezen/go-get-issue-10952", "did not detect updated import path") +} + // Test git clone URL that uses SCP-like syntax and custom import path checking. func TestIssue11457(t *testing.T) { testenv.MustHaveExternalNetwork(t) diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go index 06251a938d..fcdce220a7 100644 --- a/src/cmd/go/vcs.go +++ b/src/cmd/go/vcs.go @@ -528,6 +528,9 @@ type repoRoot struct { // root is the import path corresponding to the root of the // repository root string + + // isCustom is true for custom import paths (those defined by HTML meta tags) + isCustom bool } var httpPrefixRE = regexp.MustCompile(`^https?:`) @@ -713,9 +716,10 @@ func repoRootForImportDynamic(importPath string, security securityMode) (*repoRo return nil, fmt.Errorf("%s: invalid repo root %q; no scheme", urlStr, mmi.RepoRoot) } rr := &repoRoot{ - vcs: vcsByCmd(mmi.VCS), - repo: mmi.RepoRoot, - root: mmi.Prefix, + vcs: vcsByCmd(mmi.VCS), + repo: mmi.RepoRoot, + root: mmi.Prefix, + isCustom: true, } if rr.vcs == nil { return nil, fmt.Errorf("%s: unknown vcs %q", urlStr, mmi.VCS)