From 0951d5d7a351f937ad920681dcdbda92ba161750 Mon Sep 17 00:00:00 2001 From: sam boyer Date: Sat, 14 Oct 2017 14:36:05 -0400 Subject: [PATCH] gps: Don't drop visible packages with errors --- internal/gps/pkgtree/pkgtree.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/gps/pkgtree/pkgtree.go b/internal/gps/pkgtree/pkgtree.go index ec31d6afb5..3723981840 100644 --- a/internal/gps/pkgtree/pkgtree.go +++ b/internal/gps/pkgtree/pkgtree.go @@ -659,9 +659,10 @@ func (t PackageTree) Copy() PackageTree { // a set of tree-external imports; calling ToReachMap and FlattenFn will achieve // the same effect. func (t PackageTree) TrimHiddenPackages(main, tests, keepIgnored bool, ignore *IgnoredRuleset) PackageTree { - rm, _ := t.ToReachMap(main, tests, false, ignore) + rm, pie := t.ToReachMap(main, tests, false, ignore) t2 := t.Copy() preserve := make(map[string]bool) + for pkg, ie := range rm { if pkgFilter(pkg) && (keepIgnored || !ignore.IsIgnored(pkg)) { preserve[pkg] = true @@ -671,6 +672,14 @@ func (t PackageTree) TrimHiddenPackages(main, tests, keepIgnored bool, ignore *I } } + // Also process the problem map, as packages in the visible set with errors + // need to be included in the return values. + for pkg := range pie { + if pkgFilter(pkg) && (keepIgnored || !ignore.IsIgnored(pkg)) { + preserve[pkg] = true + } + } + for ip := range t.Packages { if !preserve[ip] { delete(t2.Packages, ip)