Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 3cc6f49

Browse files
committed
Addressed most MR comments. Still struggling with the new concurrency requests
1 parent 4f991d4 commit 3cc6f49

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

cmd/dep/root_analyzer.go

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ import (
88
"context"
99
"io/ioutil"
1010
"log"
11-
"strings"
1211

1312
"golang.org/x/sync/errgroup"
1413

1514
"github.com/golang/dep"
1615
fb "github.com/golang/dep/internal/feedback"
1716
"github.com/golang/dep/internal/gps"
18-
"github.com/golang/dep/internal/gps/paths"
1917
"github.com/golang/dep/internal/importers"
2018
)
2119

@@ -64,7 +62,6 @@ func (a *rootAnalyzer) InitializeRootManifestAndLock(dir string, pr gps.ProjectR
6462
}
6563

6664
func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) error {
67-
deps := make(map[gps.ProjectRoot]bool)
6865
logger := a.ctx.Err
6966
g, ctx := errgroup.WithContext(context.TODO())
7067
sem := make(chan struct{}, concurrency)
@@ -80,48 +77,28 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) error {
8077

8178
for ip := range a.directDeps {
8279
logger.Printf("Package %q, analyzing...", ip)
83-
if paths.IsStandardImportPath(ip) {
84-
continue
85-
}
86-
if hasImportPathPrefix(ip, string(pr)) {
87-
continue
88-
}
89-
9080
pr, err := a.sm.DeduceProjectRoot(ip)
9181
if err != nil {
9282
return err
9383
}
9484

95-
if _, ok := deps[pr]; ok {
96-
continue
97-
}
98-
9985
g.Go(func() error {
10086
select {
10187
case sem <- struct{}{}:
10288
defer func() { <-sem }()
10389
case <-ctx.Done():
10490
return ctx.Err()
10591
}
106-
err := syncDep(pr, a.sm)
107-
return err
92+
return syncDep(pr, a.sm)
10893
})
109-
110-
deps[pr] = true
11194
}
112-
if err := g.Wait(); err == nil {
113-
logger.Printf("Successfully cached all deps.")
95+
if err := g.Wait(); err != nil {
96+
return err
11497
}
98+
logger.Printf("Successfully cached all deps.")
11599
return nil
116100
}
117101

118-
func hasImportPathPrefix(s, prefix string) bool {
119-
if s == prefix {
120-
return true
121-
}
122-
return strings.HasPrefix(s, prefix+"/")
123-
}
124-
125102
func (a *rootAnalyzer) importManifestAndLock(dir string, pr gps.ProjectRoot, suppressLogs bool) (*dep.Manifest, *dep.Lock, error) {
126103
logger := a.ctx.Err
127104
if suppressLogs {

0 commit comments

Comments
 (0)