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

Commit 560c6b5

Browse files
committed
gps: check wildcard ignored and required conflict
1 parent 1e70d28 commit 560c6b5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

internal/gps/solver.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,13 @@ func (params SolveParameters) toRootdata() (rootdata, error) {
206206
rd.ovr = make(ProjectConstraints)
207207
}
208208

209+
// Create ignore prefix tree using the provided ignore packages
210+
rd.igpfx = pkgtree.CreateIgnorePrefixTree(rd.ig)
211+
209212
if len(rd.ig) != 0 {
210213
var both []string
211214
for pkg := range params.Manifest.RequiredPackages() {
212-
if rd.ig[pkg] {
215+
if rd.isIgnored(pkg) {
213216
both = append(both, pkg)
214217
}
215218
}
@@ -262,9 +265,6 @@ func (params SolveParameters) toRootdata() (rootdata, error) {
262265
rd.chng[p] = struct{}{}
263266
}
264267

265-
// Create ignore prefix tree using the provided ignore packages
266-
rd.igpfx = pkgtree.CreateIgnorePrefixTree(rd.ig)
267-
268268
return rd, nil
269269
}
270270

internal/gps/solver_inputs_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ func TestBadSolveOpts(t *testing.T) {
114114
} else if !strings.Contains(err.Error(), "multiple packages given as both required and ignored:") {
115115
t.Error("Prepare should have given error with multiple ignore/require conflict error, but gave:", err)
116116
}
117+
118+
params.Manifest = simpleRootManifest{
119+
ig: map[string]bool{"foo*": true},
120+
req: map[string]bool{"foo/bar": true},
121+
}
122+
_, err = Prepare(params, sm)
123+
if err == nil {
124+
t.Errorf("Should have errored on pkg both ignored (with wildcard) and required")
125+
} else if !strings.Contains(err.Error(), "was given as both a required and ignored package") {
126+
t.Error("Prepare should have given error with single ignore/require conflict error, but gave:", err)
127+
}
117128
params.Manifest = nil
118129

119130
params.ToChange = []ProjectRoot{"foo"}

0 commit comments

Comments
 (0)