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

Commit cf5739a

Browse files
committed
Enable glob syntax (/...) in ignored packages
Change gps.RootManifest.IgnoredPackages() to receive gps.SolveParameters. Use the SolveParameters's RootDir and RootPackageTree to ignore packages from root of the project.
1 parent 5f4284e commit cf5739a

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

internal/gps/manifest.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type RootManifest interface {
5050
//
5151
// It is an error to include a package in both the ignored and required
5252
// sets.
53-
IgnoredPackages() map[string]bool
53+
IgnoredPackages(SolveParameters) map[string]bool
5454

5555
// RequiredPackages returns a set of import paths to require. These packages
5656
// are required to be present in any solution. The list can include main
@@ -103,7 +103,7 @@ func (m simpleRootManifest) TestDependencyConstraints() ProjectConstraints {
103103
func (m simpleRootManifest) Overrides() ProjectConstraints {
104104
return m.ovr
105105
}
106-
func (m simpleRootManifest) IgnoredPackages() map[string]bool {
106+
func (m simpleRootManifest) IgnoredPackages(SolveParameters) map[string]bool {
107107
return m.ig
108108
}
109109
func (m simpleRootManifest) RequiredPackages() map[string]bool {

internal/gps/solver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (params SolveParameters) toRootdata() (rootdata, error) {
183183
}
184184

185185
rd := rootdata{
186-
ig: params.Manifest.IgnoredPackages(),
186+
ig: params.Manifest.IgnoredPackages(params),
187187
req: params.Manifest.RequiredPackages(),
188188
ovr: params.Manifest.Overrides(),
189189
rpt: params.RootPackageTree.Copy(),

manifest.go

+20-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import (
88
"bytes"
99
"fmt"
1010
"io"
11+
"path/filepath"
1112
"reflect"
1213
"regexp"
1314
"sort"
15+
"strings"
1416

1517
"github.com/golang/dep/internal/gps"
18+
"github.com/golang/dep/internal/gps/pkgtree"
1619
"github.com/pelletier/go-toml"
1720
"github.com/pkg/errors"
1821
)
@@ -282,14 +285,29 @@ func (m *Manifest) Overrides() gps.ProjectConstraints {
282285
}
283286

284287
// IgnoredPackages returns a set of import paths to ignore.
285-
func (m *Manifest) IgnoredPackages() map[string]bool {
288+
func (m *Manifest) IgnoredPackages(solveParam gps.SolveParameters) map[string]bool {
286289
if len(m.Ignored) == 0 {
287290
return nil
288291
}
289292

290293
mp := make(map[string]bool, len(m.Ignored))
291294
for _, i := range m.Ignored {
292-
mp[i] = true
295+
// Check if the path has glob syntax (/...)
296+
dir, base := filepath.Split(i)
297+
if base == "..." {
298+
pkgT, _ := pkgtree.ListPackages(filepath.Join(solveParam.RootDir, dir), dir)
299+
300+
// Ignored root packages found in package tree of ignored package
301+
for p := range pkgT.Packages {
302+
for rp := range solveParam.RootPackageTree.Packages {
303+
if strings.HasSuffix(rp, p) {
304+
mp[rp] = true
305+
}
306+
}
307+
}
308+
} else {
309+
mp[i] = true
310+
}
293311
}
294312

295313
return mp

0 commit comments

Comments
 (0)