diff --git a/go.mod b/go.mod index 131b91d36..33aa0b7fb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24 toolchain go1.24.1 require ( - github.com/bmatcuk/doublestar/v4 v4.8.1 + github.com/bmatcuk/doublestar/v4 v4.9.0 github.com/go-git/go-git/v5 v5.16.2 github.com/hashicorp/go-retryablehttp v0.7.8 github.com/iancoleman/strcase v0.3.0 diff --git a/go.sum b/go.sum index 6a493c2de..7a459270f 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38= -github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bmatcuk/doublestar/v4 v4.9.0 h1:DBvuZxjdKkRP/dr4GVV4w2fnmrk5Hxc90T51LZjv0JA= +github.com/bmatcuk/doublestar/v4 v4.9.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= diff --git a/vendor/github.com/bmatcuk/doublestar/v4/README.md b/vendor/github.com/bmatcuk/doublestar/v4/README.md index b417a2c45..e4d1941e3 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/README.md +++ b/vendor/github.com/bmatcuk/doublestar/v4/README.md @@ -138,6 +138,15 @@ Options that may be passed to `Glob`, `GlobWalk`, or `FilepathGlob`. Any number of options may be passed to these functions, and in any order, as the last argument(s). +```go +WithCaseInsensitive() +``` + +WithCaseInsensitive is an option that can be passed to Glob, GlobWalk, or +FilepathGlob. If passed, doublestar will treat all alphabetic characters as +case insensitive (i.e. "a" in the pattern would match "a" or "A"). This is +useful for platforms like Windows where paths are case insensitive by default. + ```go WithFailOnIOErrors() ``` diff --git a/vendor/github.com/bmatcuk/doublestar/v4/glob.go b/vendor/github.com/bmatcuk/doublestar/v4/glob.go index 5d8b75ede..3471bea78 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/glob.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/glob.go @@ -225,7 +225,7 @@ func (g *glob) globDir(fsys fs.FS, dir, pattern string, matches []string, canMat var matched bool for _, info := range dirs { name := info.Name() - matched, e = matchWithSeparator(pattern, name, '/', false) + matched, e = matchWithSeparator(pattern, name, '/', false, g.caseInsensitive) if e != nil { return } diff --git a/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go b/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go index 9483c4bb0..629835602 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go @@ -4,6 +4,7 @@ import "strings" // glob is an internal type to store options during globbing. type glob struct { + caseInsensitive bool failOnIOErrors bool failOnPatternNotExist bool filesOnly bool @@ -23,12 +24,21 @@ func newGlob(opts ...GlobOption) *glob { return g } +// WithCaseInsensitive is an option that can be passed to Glob, GlobWalk, or +// FilepathGlob. If passed, doublestar will treat all alphabetic characters as +// case insensitive (i.e. "a" in the pattern would match "a" or "A"). This is +// useful for platforms like Windows where paths are case insensitive by default. +func WithCaseInsensitive() GlobOption { + return func(g *glob) { + g.caseInsensitive = true + } +} + // WithFailOnIOErrors is an option that can be passed to Glob, GlobWalk, or // FilepathGlob. If passed, doublestar will abort and return IO errors when // encountered. Note that if the glob pattern references a path that does not // exist (such as `nonexistent/path/*`), this is _not_ considered an IO error: // it is considered a pattern with no matches. -// func WithFailOnIOErrors() GlobOption { return func(g *glob) { g.failOnIOErrors = true @@ -42,7 +52,6 @@ func WithFailOnIOErrors() GlobOption { // `{...}`) are expanded before this check. In other words, a pattern such as // `{a,b}/*` may fail if either `a` or `b` do not exist but `*/{a,b}` will // never fail because the star may match nothing. -// func WithFailOnPatternNotExist() GlobOption { return func(g *glob) { g.failOnPatternNotExist = true @@ -56,7 +65,6 @@ func WithFailOnPatternNotExist() GlobOption { // Note: if combined with the WithNoFollow option, symlinks to directories // _will_ be included in the result since no attempt is made to follow the // symlink. -// func WithFilesOnly() GlobOption { return func(g *glob) { g.filesOnly = true @@ -76,7 +84,6 @@ func WithFilesOnly() GlobOption { // Note: if combined with the WithFilesOnly option, symlinks to directories // _will_ be included in the result since no attempt is made to follow the // symlink. -// func WithNoFollow() GlobOption { return func(g *glob) { g.noFollow = true @@ -86,7 +93,6 @@ func WithNoFollow() GlobOption { // forwardErrIfFailOnIOErrors is used to wrap the return values of I/O // functions. When failOnIOErrors is enabled, it will return err; otherwise, it // always returns nil. -// func (g *glob) forwardErrIfFailOnIOErrors(err error) error { if g.failOnIOErrors { return err @@ -97,7 +103,6 @@ func (g *glob) forwardErrIfFailOnIOErrors(err error) error { // handleErrNotExist handles fs.ErrNotExist errors. If // WithFailOnPatternNotExist has been enabled and canFail is true, this will // return ErrPatternNotExist. Otherwise, it will return nil. -// func (g *glob) handlePatternNotExist(canFail bool) error { if canFail && g.failOnPatternNotExist { return ErrPatternNotExist @@ -111,7 +116,14 @@ func (g *glob) GoString() string { b.WriteString("opts: ") hasOpts := false + if g.caseInsensitive { + b.WriteString("WithCaseInsensitive") + hasOpts = true + } if g.failOnIOErrors { + if hasOpts { + b.WriteString(", ") + } b.WriteString("WithFailOnIOErrors") hasOpts = true } diff --git a/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go b/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go index 3c77c858c..16601b76a 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go @@ -50,7 +50,6 @@ type GlobWalkFunc func(path string, d fs.DirEntry) error // // Note: users should _not_ count on the returned error, // doublestar.ErrBadPattern, being equal to path.ErrBadPattern. -// func GlobWalk(fsys fs.FS, pattern string, fn GlobWalkFunc, opts ...GlobOption) error { if !ValidatePattern(pattern) { return ErrBadPattern @@ -290,7 +289,7 @@ func (g *glob) globDirWalk(fsys fs.FS, dir, pattern string, canMatchFiles, befor var matched bool for _, info := range dirs { name := info.Name() - matched, e = matchWithSeparator(pattern, name, '/', false) + matched, e = matchWithSeparator(pattern, name, '/', false, g.caseInsensitive) if e != nil { return } diff --git a/vendor/github.com/bmatcuk/doublestar/v4/match.go b/vendor/github.com/bmatcuk/doublestar/v4/match.go index a21259db4..3aa10f384 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/match.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/match.go @@ -2,30 +2,31 @@ package doublestar import ( "path/filepath" + "unicode" "unicode/utf8" ) // Match reports whether name matches the shell pattern. // The pattern syntax is: // -// pattern: -// { term } -// term: -// '*' matches any sequence of non-path-separators -// '/**/' matches zero or more directories -// '?' matches any single non-path-separator character -// '[' [ '^' '!' ] { character-range } ']' -// character class (must be non-empty) -// starting with `^` or `!` negates the class -// '{' { term } [ ',' { term } ... ] '}' -// alternatives -// c matches character c (c != '*', '?', '\\', '[') -// '\\' c matches character c +// pattern: +// { term } +// term: +// '*' matches any sequence of non-path-separators +// '/**/' matches zero or more directories +// '?' matches any single non-path-separator character +// '[' [ '^' '!' ] { character-range } ']' +// character class (must be non-empty) +// starting with `^` or `!` negates the class +// '{' { term } [ ',' { term } ... ] '}' +// alternatives +// c matches character c (c != '*', '?', '\\', '[') +// '\\' c matches character c // -// character-range: -// c matches character c (c != '\\', '-', ']') -// '\\' c matches character c -// lo '-' hi matches character c for lo <= c <= hi +// character-range: +// c matches character c (c != '\\', '-', ']') +// '\\' c matches character c +// lo '-' hi matches character c for lo <= c <= hi // // Match returns true if `name` matches the file name `pattern`. `name` and // `pattern` are split on forward slash (`/`) characters and may be relative or @@ -48,9 +49,8 @@ import ( // // Note: users should _not_ count on the returned error, // doublestar.ErrBadPattern, being equal to path.ErrBadPattern. -// func Match(pattern, name string) (bool, error) { - return matchWithSeparator(pattern, name, '/', true) + return matchWithSeparator(pattern, name, '/', true, false) } // MatchUnvalidated can provide a small performance improvement if you don't @@ -60,7 +60,7 @@ func Match(pattern, name string) (bool, error) { // of `name` before reaching the end of `pattern`, such as `Match("a/b/c", // "a")`. func MatchUnvalidated(pattern, name string) bool { - matched, _ := matchWithSeparator(pattern, name, '/', false) + matched, _ := matchWithSeparator(pattern, name, '/', false, false) return matched } @@ -73,9 +73,8 @@ func MatchUnvalidated(pattern, name string) bool { // assumes that both `pattern` and `name` are using the system's path // separator. If you can't be sure of that, use filepath.ToSlash() on both // `pattern` and `name`, and then use the Match() function instead. -// func PathMatch(pattern, name string) (bool, error) { - return matchWithSeparator(pattern, name, filepath.Separator, true) + return matchWithSeparator(pattern, name, filepath.Separator, true, false) } // PathMatchUnvalidated can provide a small performance improvement if you @@ -85,15 +84,15 @@ func PathMatch(pattern, name string) (bool, error) { // end of `name` before reaching the end of `pattern`, such as `Match("a/b/c", // "a")`. func PathMatchUnvalidated(pattern, name string) bool { - matched, _ := matchWithSeparator(pattern, name, filepath.Separator, false) + matched, _ := matchWithSeparator(pattern, name, filepath.Separator, false, false) return matched } -func matchWithSeparator(pattern, name string, separator rune, validate bool) (matched bool, err error) { - return doMatchWithSeparator(pattern, name, separator, validate, -1, -1, -1, -1, 0, 0) +func matchWithSeparator(pattern, name string, separator rune, validate bool, caseInsensitive bool) (matched bool, err error) { + return doMatchWithSeparator(pattern, name, separator, validate, caseInsensitive, -1, -1, -1, -1, 0, 0) } -func doMatchWithSeparator(pattern, name string, separator rune, validate bool, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, patIdx, nameIdx int) (matched bool, err error) { +func doMatchWithSeparator(pattern, name string, separator rune, validate bool, caseInsensitive bool, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, patIdx, nameIdx int) (matched bool, err error) { patLen := len(pattern) nameLen := len(name) startOfSegment := true @@ -194,7 +193,7 @@ MATCH: } // check if the rune matches - if patRune == nameRune { + if matchRune(patRune, nameRune, caseInsensitive) { matched = true break } @@ -240,14 +239,14 @@ MATCH: } commaIdx += patIdx - result, err := doMatchWithSeparator(pattern[:beforeIdx]+pattern[patIdx:commaIdx]+pattern[closingIdx+1:], name, separator, validate, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, beforeIdx, nameIdx) + result, err := doMatchWithSeparator(pattern[:beforeIdx]+pattern[patIdx:commaIdx]+pattern[closingIdx+1:], name, separator, validate, caseInsensitive, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, beforeIdx, nameIdx) if result || err != nil { return result, err } patIdx = commaIdx + 1 } - return doMatchWithSeparator(pattern[:beforeIdx]+pattern[patIdx:closingIdx]+pattern[closingIdx+1:], name, separator, validate, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, beforeIdx, nameIdx) + return doMatchWithSeparator(pattern[:beforeIdx]+pattern[patIdx:closingIdx]+pattern[closingIdx+1:], name, separator, validate, caseInsensitive, doublestarPatternBacktrack, doublestarNameBacktrack, starPatternBacktrack, starNameBacktrack, beforeIdx, nameIdx) case '\\': if separator != '\\' { @@ -262,7 +261,7 @@ MATCH: default: patRune, patRuneLen := utf8.DecodeRuneInString(pattern[patIdx:]) nameRune, nameRuneLen := utf8.DecodeRuneInString(name[nameIdx:]) - if patRune != nameRune { + if !matchRune(patRune, nameRune, caseInsensitive) { if separator != '\\' && patIdx > 0 && pattern[patIdx-1] == '\\' { // if this rune was meant to be escaped, we need to move patIdx // back to the backslash before backtracking or validating below @@ -311,17 +310,19 @@ MATCH: return false, nil } - if nameIdx < nameLen { - // we reached the end of `pattern` before the end of `name` - return false, nil - } - // we've reached the end of `name`; we've successfully matched if we've also // reached the end of `pattern`, or if the rest of `pattern` can match a // zero-length string return isZeroLengthPattern(pattern[patIdx:], separator, validate) } +func matchRune(a, b rune, caseInsensitive bool) bool { + if caseInsensitive { + return unicode.ToLower(a) == unicode.ToLower(b) + } + return a == b +} + func isZeroLengthPattern(pattern string, separator rune, validate bool) (ret bool, err error) { // `/**`, `**/`, and `/**/` are special cases - a pattern such as `path/to/a/**` or `path/to/a/**/` // *should* match `path/to/a` because `a` might be a directory diff --git a/vendor/modules.txt b/vendor/modules.txt index b1d05a3ca..fb3598304 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,7 +32,7 @@ github.com/ProtonMail/go-crypto/openpgp/packet github.com/ProtonMail/go-crypto/openpgp/s2k github.com/ProtonMail/go-crypto/openpgp/x25519 github.com/ProtonMail/go-crypto/openpgp/x448 -# github.com/bmatcuk/doublestar/v4 v4.8.1 +# github.com/bmatcuk/doublestar/v4 v4.9.0 ## explicit; go 1.16 github.com/bmatcuk/doublestar/v4 # github.com/cloudflare/circl v1.6.1