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

Commit

Permalink
Merge pull request #187 from spenczar/fix_err_shadowing_bug
Browse files Browse the repository at this point in the history
Fix err shadowing bug that caused panics for unreachable repos
  • Loading branch information
sdboyer authored Mar 10, 2017
2 parents 4b29d30 + 2c74208 commit 9a583ef
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 9a583ef

Please sign in to comment.