commit | 070e2dda0252138ebe319a4f8839d71cbf57cd2a | [log] [tgz] |
---|---|---|
author | Bryan C. Mills <bcmills@google.com> | Wed Jun 26 09:22:08 2019 -0400 |
committer | Bryan C. Mills <bcmills@google.com> | Wed Jun 26 19:12:30 2019 +0000 |
tree | e1acd6d45c40afc606248e73fbd5090ce7ff0371 | |
parent | 4047f01d314d72a72beebd26974f3971f5c015e5 [diff] |
cmd/go/internal/modfetch/codehost: don't try to execute a nonexistent fetch function This fixes a panic observed in https://build.golang.org/log/1242a032cac29fd3dffb24055fdeff0202b546be. Change-Id: I029b9d69cabb87091734bd33d7fd39d30b12f9c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/183917 Reviewed-by: Jay Conrod <jayconrod@google.com>
diff --git a/src/cmd/go/internal/modfetch/codehost/vcs.go b/src/cmd/go/internal/modfetch/codehost/vcs.go index b1845f5..48238f1 100644 --- a/src/cmd/go/internal/modfetch/codehost/vcs.go +++ b/src/cmd/go/internal/modfetch/codehost/vcs.go
@@ -341,7 +341,9 @@ } func (r *vcsRepo) fetch() { - _, r.fetchErr = Run(r.dir, r.cmd.fetch) + if len(r.cmd.fetch) > 0 { + _, r.fetchErr = Run(r.dir, r.cmd.fetch) + } } func (r *vcsRepo) statLocal(rev string) (*RevInfo, error) {
diff --git a/src/cmd/go/testdata/script/mod_get_svn.txt b/src/cmd/go/testdata/script/mod_get_svn.txt index e89bb9d..90be737 100644 --- a/src/cmd/go/testdata/script/mod_get_svn.txt +++ b/src/cmd/go/testdata/script/mod_get_svn.txt
@@ -13,6 +13,12 @@ ! go install . stderr 'ReadZip not implemented for svn' +# Attempting to get a nonexistent module using svn should fail with a +# reasonable message instead of a panic. +! go get -d vcs-test.golang.org/svn/nonexistent.svn +! stderr panic +stderr 'go get vcs-test.golang.org/svn/nonexistent.svn: no matching versions for query "latest"' + -- go.mod -- module golang/go/issues/28943/main -- main.go --