]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfetch/codehost: don't try to execute a nonexistent fetch function
authorBryan C. Mills <bcmills@google.com>
Wed, 26 Jun 2019 13:22:08 +0000 (09:22 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 26 Jun 2019 19:12:30 +0000 (19:12 +0000)
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>
src/cmd/go/internal/modfetch/codehost/vcs.go
src/cmd/go/testdata/script/mod_get_svn.txt

index b1845f5c65067691ee6edc3bcd2f107c7c3e420e..48238f176c6dae63b0f09c1d76e966df2c9feee2 100644 (file)
@@ -341,7 +341,9 @@ func (r *vcsRepo) Stat(rev string) (*RevInfo, error) {
 }
 
 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) {
index e89bb9d9f5e65fb7aa2827278ad96c6c212d20e2..90be737213a95d8ec8b102637f1caa7f6d255ac4 100644 (file)
@@ -13,6 +13,12 @@ stderr 'ReadZip not implemented for svn'
 ! 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 --