tg.grepStderr("found import comments", "go build did not mention comment conflict")
}
-// cmd/go: custom import path checking should not apply to github.com/xxx/yyy.
+// cmd/go: custom import path checking should not apply to Go packages without import comment.
func TestIssue10952(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
if _, err := exec.LookPath("git"); err != nil {
tg.run("get", "-d", "-u", importPath)
}
+// Test git clone URL that uses SCP-like syntax and custom import path checking.
+func TestIssue11457(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("."))
+ const importPath = "github.com/rsc/go-get-issue-11457"
+ tg.run("get", "-d", "-u", importPath)
+ repoDir := tg.path("src/" + importPath)
+ tg.runGit(repoDir, "remote", "set-url", "origin", "git@github.com:rsc/go-get-issue-11457")
+
+ // At this time, custom import path checking compares remotes verbatim (rather than
+ // just the host and path, skipping scheme and user), so we expect go get -u to fail.
+ // However, the goal of this test is to verify that gitRemoteRepo correctly parsed
+ // the SCP-like syntax, and we expect it to appear in the error message.
+ tg.runFail("get", "-d", "-u", importPath)
+ want := " is checked out from ssh://git@github.com/rsc/go-get-issue-11457"
+ if !strings.HasSuffix(strings.TrimSpace(tg.getStderr()), want) {
+ t.Error("expected clone URL to appear in stderr")
+ }
+}
+
func TestGetGitDefaultBranch(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
if _, err := exec.LookPath("git"); err != nil {
tg.grepStderr("no buildable Go source files", "did not complain about missing sources")
tg.tempFile("src/p1/missing.go", `//go:binary-only-package
-
+
package p1
func G()
`)