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

Fix err shadowing bug that caused panics for unreachable repos #187

Merged
merged 1 commit into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}