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

Commit fbf21bd

Browse files
committed
Logging out a message to the user whenever a new dependency is found.
1 parent 6a70bc2 commit fbf21bd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/dep/init.go

+13
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
166166
if err := sw.WriteAllSafe(false); err != nil {
167167
return errors.Wrap(err, "safe write of manifest and lock")
168168
}
169+
169170
return nil
170171
}
171172

@@ -237,6 +238,15 @@ func getProjectData(ctx *dep.Ctx, pkgT gps.PackageTree, cpr string, sm *gps.Sour
237238
packages := make(map[string]bool)
238239
notondisk := make(map[gps.ProjectRoot]bool)
239240
ondisk := make(map[gps.ProjectRoot]gps.Version)
241+
242+
syncDep := func(pr gps.ProjectRoot, sm *gps.SourceMgr) {
243+
message := "Cached"
244+
if err := sm.SyncSourceFor(gps.ProjectIdentifier{ProjectRoot: pr}); err != nil {
245+
message = "Unable to cache"
246+
}
247+
fmt.Fprintf(os.Stderr, "%s %s\n", message, pr)
248+
}
249+
240250
for _, v := range pkgT.Packages {
241251
// TODO: Some errors maybe should not be skipped ;-)
242252
if v.Err != nil {
@@ -266,6 +276,8 @@ func getProjectData(ctx *dep.Ctx, pkgT gps.PackageTree, cpr string, sm *gps.Sour
266276

267277
continue
268278
}
279+
go syncDep(pr, sm)
280+
269281
vlogf("Package %q has import %q, analyzing...", v.P.ImportPath, ip)
270282

271283
dependencies[pr] = []string{ip}
@@ -363,6 +375,7 @@ func getProjectData(ctx *dep.Ctx, pkgT gps.PackageTree, cpr string, sm *gps.Sour
363375
}
364376
} else {
365377
dependencies[pr] = []string{pkg}
378+
go syncDep(pr, sm)
366379
}
367380

368381
// project must be on disk at this point; question is

0 commit comments

Comments
 (0)