Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Use doublestar for globbing
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Sep 16, 2021
1 parent 10778e2 commit 2c3defd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions internal/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ github.com/google/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEi
github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
Expand Down
4 changes: 1 addition & 3 deletions operator/builtin/input/file/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package file

import (
"path/filepath"

"github.com/bmatcuk/doublestar/v3"
)

Expand All @@ -29,7 +27,7 @@ type Finder struct {
func (f Finder) FindFiles() []string {
all := make([]string, 0, len(f.Include))
for _, include := range f.Include {
matches, _ := filepath.Glob(include) // compile error checked in build
matches, _ := doublestar.Glob(include) // compile error checked in build
INCLUDE:
for _, match := range matches {
for _, exclude := range f.Exclude {
Expand Down
21 changes: 7 additions & 14 deletions operator/builtin/input/file/finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ func TestFinder(t *testing.T) {
exclude: []string{"exclude.log"},
expected: []string{"include.log"},
},
// {
// name: "ExcludeEmpty",
// files: []string{"include.log", "exclude.log"},
// include: []string{"*"},
// exclude: []string{"exclude.log"},
// expected: []string{"include.log", "exclude.log"},
// },
{
name: "ExcludeMany",
files: []string{"a1.log", "a2.log", "b1.log", "b2.log"},
Expand Down Expand Up @@ -125,13 +118,13 @@ func TestFinder(t *testing.T) {
exclude: []string{},
expected: []string{"a/1.log", "b/1.log", "c/1.log"},
},
// {
// name: "DoubleStarVaryingDepth",
// files: []string{"1.log", "a/1.log", "a/b/1.log", "c/1.log"},
// include: []string{"**/*.log"},
// exclude: []string{},
// expected: []string{"1.log", "a/1.log", "a/b/1.log", "c/1.log"},
// },
{
name: "DoubleStarVaryingDepth",
files: []string{"1.log", "a/1.log", "a/b/1.log", "c/1.log"},
include: []string{"**/*.log"},
exclude: []string{},
expected: []string{"1.log", "a/1.log", "a/b/1.log", "c/1.log"},
},
}

for _, tc := range cases {
Expand Down

0 comments on commit 2c3defd

Please sign in to comment.