From 3cc6f49aa9e5e85f4c81009cae837d368d251aff Mon Sep 17 00:00:00 2001 From: mstrong Date: Wed, 11 Oct 2017 19:46:56 -0500 Subject: [PATCH] Addressed most MR comments. Still struggling with the new concurrency requests --- cmd/dep/root_analyzer.go | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/cmd/dep/root_analyzer.go b/cmd/dep/root_analyzer.go index 978536c03f..9420f325cb 100644 --- a/cmd/dep/root_analyzer.go +++ b/cmd/dep/root_analyzer.go @@ -8,14 +8,12 @@ import ( "context" "io/ioutil" "log" - "strings" "golang.org/x/sync/errgroup" "github.com/golang/dep" fb "github.com/golang/dep/internal/feedback" "github.com/golang/dep/internal/gps" - "github.com/golang/dep/internal/gps/paths" "github.com/golang/dep/internal/importers" ) @@ -64,7 +62,6 @@ func (a *rootAnalyzer) InitializeRootManifestAndLock(dir string, pr gps.ProjectR } func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) error { - deps := make(map[gps.ProjectRoot]bool) logger := a.ctx.Err g, ctx := errgroup.WithContext(context.TODO()) sem := make(chan struct{}, concurrency) @@ -80,22 +77,11 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) error { for ip := range a.directDeps { logger.Printf("Package %q, analyzing...", ip) - if paths.IsStandardImportPath(ip) { - continue - } - if hasImportPathPrefix(ip, string(pr)) { - continue - } - pr, err := a.sm.DeduceProjectRoot(ip) if err != nil { return err } - if _, ok := deps[pr]; ok { - continue - } - g.Go(func() error { select { case sem <- struct{}{}: @@ -103,25 +89,16 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) error { case <-ctx.Done(): return ctx.Err() } - err := syncDep(pr, a.sm) - return err + return syncDep(pr, a.sm) }) - - deps[pr] = true } - if err := g.Wait(); err == nil { - logger.Printf("Successfully cached all deps.") + if err := g.Wait(); err != nil { + return err } + logger.Printf("Successfully cached all deps.") return nil } -func hasImportPathPrefix(s, prefix string) bool { - if s == prefix { - return true - } - return strings.HasPrefix(s, prefix+"/") -} - func (a *rootAnalyzer) importManifestAndLock(dir string, pr gps.ProjectRoot, suppressLogs bool) (*dep.Manifest, *dep.Lock, error) { logger := a.ctx.Err if suppressLogs {