Skip to content

Commit 12dfc94

Browse files
Bryan C. Millsromaindoumenc
Bryan C. Mills
authored andcommitted
cmd/go: redirect vcs-test.golang.org repo URLs to a test-local server
The new server reconstructs the vcs-test repos on the fly using scripts that run the actual version-control binaries. This allows those repos to be code-reviewed using our normal tools — and, crucially, allows contributors to add new vcs-test contents as part of a contributed CL. It also prevents failures due to network errors reaching vcs-test.golang.org (such as when developing offline), and allows us to iterate on the repo contents without dealing with annoying and unpredictable GCS caching behavior. We can't quite turn down vcs-test.golang.org yet — this server doesn't yet handle "go-import" metadata (and related authentication behaviors), and doesn't serve Subversion repos. But we're getting much closer! For golang#27494. Change-Id: I233fc718617aed287b0f7248bd8cfe1e5cebe96b Reviewed-on: https://go-review.googlesource.com/c/go/+/421455 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent cfe4d02 commit 12dfc94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3644
-461
lines changed

src/cmd/go/go_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
"cmd/go/internal/cfg"
3434
"cmd/go/internal/robustio"
3535
"cmd/go/internal/search"
36+
"cmd/go/internal/vcs"
37+
"cmd/go/internal/vcweb/vcstest"
3638
"cmd/go/internal/work"
3739
"cmd/internal/sys"
3840

@@ -129,6 +131,12 @@ func TestMain(m *testing.M) {
129131
return fmt.Errorf("%stestgo must not write to GOROOT (installing to %s)", callerPos, filepath.Join("GOROOT", rel))
130132
}
131133
}
134+
135+
if vcsTest := os.Getenv("TESTGO_VCSTEST_URL"); vcsTest != "" {
136+
vcs.VCSTestRepoURL = vcsTest
137+
vcs.VCSTestHosts = vcstest.Hosts
138+
}
139+
132140
cmdgo.Main()
133141
os.Exit(0)
134142
}

src/cmd/go/internal/get/get.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,21 +495,21 @@ func downloadPackage(p *load.Package) error {
495495
vcsCmd, repo, rootPath = rr.VCS, rr.Repo, rr.Root
496496
}
497497
if !blindRepo && !vcsCmd.IsSecure(repo) && security != web.Insecure {
498-
return fmt.Errorf("cannot download, %v uses insecure protocol", repo)
498+
return fmt.Errorf("cannot download: %v uses insecure protocol", repo)
499499
}
500500

501501
if p.Internal.Build.SrcRoot == "" {
502502
// Package not found. Put in first directory of $GOPATH.
503503
list := filepath.SplitList(cfg.BuildContext.GOPATH)
504504
if len(list) == 0 {
505-
return fmt.Errorf("cannot download, $GOPATH not set. For more details see: 'go help gopath'")
505+
return fmt.Errorf("cannot download: $GOPATH not set. For more details see: 'go help gopath'")
506506
}
507507
// Guard against people setting GOPATH=$GOROOT.
508508
if filepath.Clean(list[0]) == filepath.Clean(cfg.GOROOT) {
509-
return fmt.Errorf("cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'")
509+
return fmt.Errorf("cannot download: $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'")
510510
}
511511
if _, err := os.Stat(filepath.Join(list[0], "src/cmd/go/alldocs.go")); err == nil {
512-
return fmt.Errorf("cannot download, %s is a GOROOT, not a GOPATH. For more details see: 'go help gopath'", list[0])
512+
return fmt.Errorf("cannot download: %s is a GOROOT, not a GOPATH. For more details see: 'go help gopath'", list[0])
513513
}
514514
p.Internal.Build.Root = list[0]
515515
p.Internal.Build.SrcRoot = filepath.Join(list[0], "src")

0 commit comments

Comments
 (0)