Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb211a7

Browse files
committedNov 20, 2017
status: Exclude pkgs not in depgraph from project status
1 parent ae10ff2 commit cb211a7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎cmd/dep/status.go

+14
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,15 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
839839
// Collect reachmap of all the locked projects.
840840
reachmaps := make(map[string]pkgtree.ReachMap)
841841

842+
// Create a list of depgraph packages to be used to exclude packages that
843+
// the root project does not use.
844+
rootPkgTree, err := p.ParseRootPackageTree()
845+
if err != nil {
846+
return err
847+
}
848+
rootrm, _ := rootPkgTree.ToReachMap(true, true, false, p.Manifest.IgnoredPackages())
849+
depgraphPkgs := rootrm.FlattenFn(paths.IsStandardImportPath)
850+
842851
// Collect and store all the necessary data from pkgtree(s).
843852
// TODO: Make this concurrent.
844853
for _, pl := range p.Lock.Projects() {
@@ -878,6 +887,11 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
878887
}
879888

880889
for pkg, ie := range rmap {
890+
// Exclude packages not used by root project.
891+
if !contains(depgraphPkgs, pkg) {
892+
continue
893+
}
894+
881895
// Iterate through the external imports and check if they
882896
// import any package from the target project.
883897
for _, p := range ie.External {

‎cmd/dep/testdata/harness_tests/status/project_status/stdout.txt

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ SOURCE TYPE: git
1313
PACKAGES: github.com/sdboyer/deptest
1414
PROJECT IMPORTERS: github.com/darkowlzz/deptest-project-status, github.com/sdboyer/deptestdos
1515
PACKAGE IMPORTERS: github.com/sdboyer/deptest
16-
github.com/darkowlzz/deptest-project-status/pkgbar
1716
github.com/darkowlzz/deptest-project-status/pkgfoo
1817
github.com/sdboyer/deptestdos
1918
UPSTREAM EXISTS: yes

0 commit comments

Comments
 (0)
This repository has been archived.