]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix test for moved package in go get -u
authorRuss Cox <rsc@golang.org>
Fri, 21 Oct 2016 14:45:47 +0000 (10:45 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 24 Oct 2016 15:17:47 +0000 (15:17 +0000)
What matters during go get -u is not whether there is an import comment
but whether we resolved the path by an HTML <meta> tag.

Fixes #16471.

Change-Id: I6b194a3f73a7962a0170b4d5cf51cfed74e02c00
Reviewed-on: https://go-review.googlesource.com/31658
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
src/cmd/go/get.go
src/cmd/go/go_test.go
src/cmd/go/vcs.go

index 4f7562b43db21900effbd73c09e8e91c989eb4f6..d5e2aab0ebebe629c5acd45f122cfdbeb0243c02 100644 (file)
@@ -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)
                                        }
                                }
index 2f883c94df69c7e464dfebff6491d577aa7c981f..33fc462339dd6f75506d44effe6c567534a17d12 100644 (file)
@@ -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)
index 06251a938d4084bcf84b716f3ef1d6aadd6fbe4f..fcdce220a7c478af19e21616891f54ed91f5fb3d 100644 (file)
@@ -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)