Skip to content

Commit

Permalink
Support ** for LargeFiles patterns.
Browse files Browse the repository at this point in the history
This is done by simply changing from filepath.Match to
doublestar.PathMatch. A few minor tests are included.

The only syntax change is that ** now matches any number of directories,
so "**/*.lock" will match a file with a "lock" extension anywhere in the
path. Since "**" had no special meaning before, this change should not
cause any surprising changes.

Change-Id: Ifbbc8227fa235372521cfbe517ce338920091eef
  • Loading branch information
Ryan Hitchman committed Jun 9, 2021
1 parent 43b32ad commit 8d919ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build/builder.go
Expand Up @@ -35,6 +35,7 @@ import (
"strings"
"sync"

"github.com/bmatcuk/doublestar"
"github.com/google/zoekt"
"github.com/google/zoekt/ctags"
)
Expand Down Expand Up @@ -79,9 +80,10 @@ type Options struct {
// Write memory profiles to this file.
MemProfile string

// LargeFiles is a slice of glob patterns where matching file
// paths should be indexed regardless of their size. The pattern syntax
// can be found here: https://golang.org/pkg/path/filepath/#Match.
// LargeFiles is a slice of glob patterns, including ** for any number
// of directories, where matching file paths should be indexed
// regardless of their size. The full pattern syntax is here:
// https://github.com/bmatcuk/doublestar/tree/v1#patterns.
LargeFiles []string
}

Expand Down Expand Up @@ -244,7 +246,7 @@ func (o *Options) IncrementalSkipIndexing() bool {
func (o *Options) IgnoreSizeMax(name string) bool {
for _, pattern := range o.LargeFiles {
pattern = strings.TrimSpace(pattern)
m, _ := filepath.Match(pattern, name)
m, _ := doublestar.PathMatch(pattern, name)
if m {
return true
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
github.com/andygrunwald/go-gerrit v0.0.0-20191101112536-3f5e365ccf57
github.com/bmatcuk/doublestar v1.3.4
github.com/fsnotify/fsnotify v1.4.7
github.com/gfleury/go-bitbucket-v1 v0.0.0-20200104105711-ddbafbb02522
github.com/go-git/go-git/v5 v5.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -16,6 +16,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down

0 comments on commit 8d919ba

Please sign in to comment.