Skip to content

Commit

Permalink
cmd/go/internal/modfetch/codehost: don't try to execute a nonexistent…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Bryan C. Mills committed Jun 26, 2019
1 parent 4047f01 commit 070e2dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmd/go/internal/modfetch/codehost/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/go/testdata/script/mod_get_svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down

0 comments on commit 070e2dd

Please sign in to comment.