diff --git a/go.mod b/go.mod index 3875dd4bf..9156ff649 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/argoproj/pkg v0.13.7-0.20250305113207-cbc37dc61de5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect + github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect github.com/bombsimon/logrusr/v4 v4.1.0 // indirect github.com/bradleyfalzon/ghinstallation/v2 v2.14.0 // indirect diff --git a/go.sum b/go.sum index 215decb5a..b54f05aee 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -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.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= +github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bombsimon/logrusr/v4 v4.1.0 h1:uZNPbwusB0eUXlO8hIUwStE6Lr5bLN6IgYgG+75kuh4= 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..1ff50f617 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,27 +310,44 @@ 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 - if pattern == "" || - pattern == "*" || - pattern == "**" || - pattern == string(separator)+"**" || - pattern == "**"+string(separator) || - pattern == string(separator)+"**"+string(separator) { + // *should* match `path/to/a` because `a` might be a directory. + // This code is optimized to avoid string concatenation, giving a little performance bump. + switch len(pattern) { + case 0: return true, nil + case 1: + if pattern == "*" { + return true, nil + } + case 2: + if pattern == "**" { + return true, nil + } + case 3: + if pattern[1:] == "**" && rune(pattern[0]) == separator { + return true, nil + } else if pattern[:2] == "**" && rune(pattern[2]) == separator { + return true, nil + } + case 4: + if pattern[1:3] == "**" && rune(pattern[0]) == separator && rune(pattern[3]) == separator { + return true, nil + } } if pattern[0] == '{' { diff --git a/vendor/modules.txt b/vendor/modules.txt index cfcc69d47..0a5ac3820 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -183,7 +183,7 @@ github.com/beorn7/perks/quantile # github.com/blang/semver/v4 v4.0.0 ## explicit; go 1.14 github.com/blang/semver/v4 -# github.com/bmatcuk/doublestar/v4 v4.8.1 +# github.com/bmatcuk/doublestar/v4 v4.9.1 ## explicit; go 1.16 github.com/bmatcuk/doublestar/v4 # github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869