Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
Fix err shadowing bug that caused panics for unreachable repos
Browse files Browse the repository at this point in the history
  • Loading branch information
spenczar committed Mar 10, 2017
1 parent 4b29d30 commit 2c74208
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions deduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ func (sm *SourceMgr) deduceFromPath(path string) (deductionFuture, error) {
defer close(c)
// make sure the metadata future is finished (without errors), thus
// guaranteeing that ru and vcs will be populated
_, err := root()
_, err = root()
if err != nil {
return
}
Expand Down Expand Up @@ -683,7 +683,6 @@ func (sm *SourceMgr) deduceFromPath(path string) (deductionFuture, error) {
return src, ident, err
}
}

return deductionFuture{
rslow: true,
root: root,
Expand Down
14 changes: 14 additions & 0 deletions manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,3 +850,17 @@ func TestSignalHandling(t *testing.T) {
}
clean()
}

func TestUnreachableSource(t *testing.T) {
// If a git remote is unreachable (maybe the server is only accessible behind a VPN, or
// something), we should return a clear error, not a panic.

sm, clean := mkNaiveSM(t)
defer clean()

id := mkPI("golang.org/notareal/repo").normalize()
_, err := sm.ListVersions(id)
if err == nil {
t.Error("expected err when listing versions of a bogus source, but got nil")
}
}

0 comments on commit 2c74208

Please sign in to comment.