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

Commit 893b197

Browse files
committed
gps: wildcard ignore skip ineffectual ignores
1 parent 1e80e66 commit 893b197

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

internal/gps/pkgtree/pkgtree.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,12 @@ func CreateIgnorePrefixTree(ig map[string]bool) *radix.Tree {
962962
if xt == nil {
963963
xt = radix.New()
964964
}
965+
// Check if it is ineffectual.
966+
_, _, ok := xt.LongestPrefix(i)
967+
if ok {
968+
// Skip ineffectual wildcard ignore.
969+
continue
970+
}
965971
// Create the ignore prefix and insert in the radix tree.
966972
i = strings.TrimSuffix(i, wcIgnoreSuffix)
967973
xt.Insert(i, true)

internal/gps/pkgtree/pkgtree_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,17 @@ func TestCreateIgnorePrefixTree(t *testing.T) {
20282028
wantInTree: []string{"gophers", "x/y/z"},
20292029
notWantInTree: []string{"*", "a/b/c"},
20302030
},
2031+
{
2032+
name: "ineffectual ignore with wildcard",
2033+
ignoreMap: map[string]bool{
2034+
"a/b*": true,
2035+
"a/b/c*": true,
2036+
"a/b/x/y": true,
2037+
"a/c*": true,
2038+
},
2039+
wantInTree: []string{"a/b", "a/c"},
2040+
notWantInTree: []string{"a/b/c", "a/b/x/y"},
2041+
},
20312042
}
20322043

20332044
for _, c := range cases {

0 commit comments

Comments
 (0)