From 4815cd5da310e1715127afe2f5fa1c6093c5dcab Mon Sep 17 00:00:00 2001 From: sam boyer Date: Fri, 23 Dec 2016 23:19:13 -0500 Subject: [PATCH] Defer ListVersions() on already-fetched git repos This was causing potentially unnecessary network activity, as well as placing a block that effectively serialized slow points in the solving algorithm. --- maybe_source.go | 18 ++++++++++-------- source_manager.go | 1 - 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/maybe_source.go b/maybe_source.go index 8c5191c..d59962a 100644 --- a/maybe_source.go +++ b/maybe_source.go @@ -82,10 +82,11 @@ func (m maybeGitSource) try(cachedir string, an ProjectAnalyzer) (source, string } src.baseVCSSource.lvfunc = src.listVersions - - _, err = src.listVersions() - if err != nil { - return nil, "", err + if !r.CheckLocal() { + _, err = src.listVersions() + if err != nil { + return nil, "", err + } } return src, ustr, nil @@ -129,10 +130,11 @@ func (m maybeGopkginSource) try(cachedir string, an ProjectAnalyzer) (source, st } src.baseVCSSource.lvfunc = src.listVersions - - _, err = src.listVersions() - if err != nil { - return nil, "", err + if !r.CheckLocal() { + _, err = src.listVersions() + if err != nil { + return nil, "", err + } } return src, ustr, nil diff --git a/source_manager.go b/source_manager.go index d5fe252..ce86307 100644 --- a/source_manager.go +++ b/source_manager.go @@ -305,7 +305,6 @@ func (sm *SourceMgr) DeduceProjectRoot(ip string) (ProjectRoot, error) { } func (sm *SourceMgr) getSourceFor(id ProjectIdentifier) (source, error) { - //pretty.Println(id.ProjectRoot) nn := id.netName() sm.srcmut.RLock()