Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package chezmoi for openSUSE:Factory checked in at 2022-11-10 14:23:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/chezmoi (Old) and /work/SRC/openSUSE:Factory/.chezmoi.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "chezmoi" Thu Nov 10 14:23:00 2022 rev:4 rq:1034914 version:2.27.0 Changes: -------- --- /work/SRC/openSUSE:Factory/chezmoi/chezmoi.changes 2022-11-02 14:19:47.833265606 +0100 +++ /work/SRC/openSUSE:Factory/.chezmoi.new.1597/chezmoi.changes 2022-11-10 14:23:36.634800023 +0100 @@ -1,0 +2,20 @@ +Wed Nov 09 18:01:27 UTC 2022 - Filippo Bonazzi <filippo.bona...@suse.com> + +- Update to version 2.27.0: + feat: Suppress newlines from onepasswordRead + feat: Allow modify_ scripts to be executed as templates + chore: Blacklist buggy version of github.com/bmatcuk/doublestar/v4 + feat: Add line ending template directive + feat: Add setValueAtPath template function + fix: Don't merge non-files in merge-all command + feat: Add --script-contents flag to diff command + chore: Better handle errors when globbing + feat: Add cat-config and dump-config commands + chore: Remove unused field + chore: Refactor handling of annotations + feat: Allow prompt*Once template functions to take paths + fix: Fix exclusion of externals + chore: Update dependencies + feat: Add completion template function + +------------------------------------------------------------------- Old: ---- chezmoi-2.26.0.obscpio New: ---- chezmoi-2.27.0.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ chezmoi.spec ++++++ --- /var/tmp/diff_new_pack.yaANFu/_old 2022-11-10 14:23:37.390804302 +0100 +++ /var/tmp/diff_new_pack.yaANFu/_new 2022-11-10 14:23:37.394804324 +0100 @@ -17,7 +17,7 @@ Name: chezmoi -Version: 2.26.0 +Version: 2.27.0 Release: 0 Summary: A multi-host manager for dotfiles License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.yaANFu/_old 2022-11-10 14:23:37.422804483 +0100 +++ /var/tmp/diff_new_pack.yaANFu/_new 2022-11-10 14:23:37.426804506 +0100 @@ -2,7 +2,7 @@ <service name="obs_scm" mode="manual"> <param name="scm">git</param> <param name="url">https://github.com/twpayne/chezmoi.git</param> - <param name="revision">v2.26.0</param> + <param name="revision">v2.27.0</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.yaANFu/_old 2022-11-10 14:23:37.442804596 +0100 +++ /var/tmp/diff_new_pack.yaANFu/_new 2022-11-10 14:23:37.446804619 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/twpayne/chezmoi.git</param> - <param name="changesrevision">2b6393e005972343a4aba3d57399cf4d83b2bb55</param></service></servicedata> + <param name="changesrevision">92993ed1f980340876a1b44e39ba382c41309053</param></service></servicedata> (No newline at EOF) ++++++ chezmoi-2.26.0.obscpio -> chezmoi-2.27.0.obscpio ++++++ ++++ 4000 lines of diff (skipped) ++++++ chezmoi.obsinfo ++++++ --- /var/tmp/diff_new_pack.yaANFu/_old 2022-11-10 14:23:37.786806543 +0100 +++ /var/tmp/diff_new_pack.yaANFu/_new 2022-11-10 14:23:37.790806566 +0100 @@ -1,5 +1,5 @@ name: chezmoi -version: 2.26.0 -mtime: 1667218318 -commit: 2b6393e005972343a4aba3d57399cf4d83b2bb55 +version: 2.27.0 +mtime: 1667872507 +commit: 92993ed1f980340876a1b44e39ba382c41309053 ++++++ vendor.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/README.md new/vendor/github.com/bmatcuk/doublestar/v4/README.md --- old/vendor/github.com/bmatcuk/doublestar/v4/README.md 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/README.md 2022-11-09 19:01:28.000000000 +0100 @@ -56,6 +56,16 @@ ## Usage +### ErrBadPattern + +```go +doublestar.ErrBadPattern +``` + +Returned by various functions to report that the pattern is malformed. At the +moment, this value is equal to `path.ErrBadPattern`, but, for portability, this +equivalence should probably not be relied upon. + ### Match ```go @@ -67,7 +77,7 @@ and may be relative or absolute. Match requires pattern to match all of name, not just a substring. The only -possible returned error is ErrBadPattern, when pattern is malformed. +possible returned error is `ErrBadPattern`, when pattern is malformed. Note: this is meant as a drop-in replacement for `path.Match()` which always uses `'/'` as the path separator. If you want to support systems which use a @@ -75,6 +85,9 @@ Alternatively, you can run `filepath.ToSlash()` on both pattern and name and then use this function. +Note: users should _not_ count on the returned error, +`doublestar.ErrBadPattern`, being equal to `path.ErrBadPattern`. + ### PathMatch @@ -92,19 +105,37 @@ can't be sure of that, use `filepath.ToSlash()` on both `pattern` and `name`, and then use the `Match()` function instead. +### GlobOption + +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 +WithFailOnIOErrors() +``` + +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. + ### Glob ```go -func Glob(fsys fs.FS, pattern string) ([]string, error) +func Glob(fsys fs.FS, pattern string, opts ...GlobOption) ([]string, error) ``` Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in `Match()`. The pattern may describe hierarchical names such as `usr/*/bin/ed`. -Glob ignores file system errors such as I/O errors reading directories. The -only possible returned error is ErrBadPattern, reporting that the pattern is -malformed. +Glob ignores file system errors such as I/O errors reading directories by +default. The only possible returned error is `ErrBadPattern`, reporting that +the pattern is malformed. + +To enable aborting on I/O errors, the `WithFailOnIOErrors` option can be +passed. Note: this is meant as a drop-in replacement for `io/fs.Glob()`. Like `io/fs.Glob()`, this function assumes that your pattern uses `/` as the path @@ -118,12 +149,15 @@ even if counter-intuitive. You can use [SplitPattern] to divide a pattern into a base path (to initialize an `FS` object) and pattern. +Note: users should _not_ count on the returned error, +`doublestar.ErrBadPattern`, being equal to `path.ErrBadPattern`. + ### GlobWalk ```go type GlobWalkFunc func(path string, d fs.DirEntry) error -func GlobWalk(fsys fs.FS, pattern string, fn GlobWalkFunc) error +func GlobWalk(fsys fs.FS, pattern string, fn GlobWalkFunc, opts ...GlobOption) error ``` GlobWalk calls the callback function `fn` for every file matching pattern. The @@ -141,8 +175,13 @@ directory, GlobWalk will not recurse into it. If the current path is not a directory, the rest of the parent directory will be skipped. -GlobWalk ignores file system errors such as I/O errors reading directories. -GlobWalk may return ErrBadPattern, reporting that the pattern is malformed. +GlobWalk ignores file system errors such as I/O errors reading directories by +default. GlobWalk may return `ErrBadPattern`, reporting that the pattern is +malformed. + +To enable aborting on I/O errors, the `WithFailOnIOErrors` option can be +passed. + Additionally, if the callback function `fn` returns an error, GlobWalk will exit immediately and return that error. @@ -151,19 +190,25 @@ sure if that's the case, you can use filepath.ToSlash() on your pattern before calling GlobWalk(). +Note: users should _not_ count on the returned error, +`doublestar.ErrBadPattern`, being equal to `path.ErrBadPattern`. + ### FilepathGlob ```go -func FilepathGlob(pattern string) (matches []string, err error) +func FilepathGlob(pattern string, opts ...GlobOption) (matches []string, err error) ``` FilepathGlob returns the names of all files matching pattern or nil if there is no matching file. The syntax of pattern is the same as in Match(). The pattern may describe hierarchical names such as usr/*/bin/ed. -FilepathGlob ignores file system errors such as I/O errors reading directories. -The only possible returned error is ErrBadPattern, reporting that the pattern -is malformed. +FilepathGlob ignores file system errors such as I/O errors reading directories +by default. The only possible returned error is `ErrBadPattern`, reporting that +the pattern is malformed. + +To enable aborting on I/O errors, the `WithFailOnIOErrors` option can be +passed. Note: FilepathGlob is a convenience function that is meant as a drop-in replacement for `path/filepath.Glob()` for users who don't need the @@ -177,6 +222,9 @@ Returned paths will use the system's path separator, just like `filepath.Glob()`. +Note: the returned error `doublestar.ErrBadPattern` is not equal to +`filepath.ErrBadPattern`. + ### SplitPattern ```go diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/glob.go new/vendor/github.com/bmatcuk/doublestar/v4/glob.go --- old/vendor/github.com/bmatcuk/doublestar/v4/glob.go 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/glob.go 2022-11-09 19:01:28.000000000 +0100 @@ -1,6 +1,7 @@ package doublestar import ( + "errors" "io/fs" "path" ) @@ -9,9 +10,12 @@ // matching file. The syntax of pattern is the same as in Match(). The pattern // may describe hierarchical names such as usr/*/bin/ed. // -// Glob ignores file system errors such as I/O errors reading directories. -// The only possible returned error is ErrBadPattern, reporting that the -// pattern is malformed. +// Glob ignores file system errors such as I/O errors reading directories by +// default. The only possible returned error is ErrBadPattern, reporting that +// the pattern is malformed. +// +// To enable aborting on I/O errors, the WithFailOnIOErrors option can be +// passed. // // Note: this is meant as a drop-in replacement for io/fs.Glob(). Like // io/fs.Glob(), this function assumes that your pattern uses `/` as the path @@ -23,27 +27,33 @@ // will return no results and no errors. You can use SplitPattern to divide a // pattern into a base path (to initialize an `FS` object) and pattern. // -func Glob(fsys fs.FS, pattern string) ([]string, error) { +// Note: users should _not_ count on the returned error, +// doublestar.ErrBadPattern, being equal to path.ErrBadPattern. +// +func Glob(fsys fs.FS, pattern string, opts ...GlobOption) ([]string, error) { if !ValidatePattern(pattern) { return nil, ErrBadPattern } + + g := newGlob(opts...) + if hasMidDoubleStar(pattern) { // If the pattern has a `**` anywhere but the very end, GlobWalk is more // performant because it can get away with less allocations. If the pattern // ends in a `**`, both methods are pretty much the same, but Glob has a // _very_ slight advantage because of lower function call overhead. var matches []string - err := doGlobWalk(fsys, pattern, true, func(p string, d fs.DirEntry) error { + err := g.doGlobWalk(fsys, pattern, true, func(p string, d fs.DirEntry) error { matches = append(matches, p) return nil }) return matches, err } - return doGlob(fsys, pattern, nil, true) + return g.doGlob(fsys, pattern, nil, true) } // Does the actual globbin' -func doGlob(fsys fs.FS, pattern string, m []string, firstSegment bool) (matches []string, err error) { +func (g *glob) doGlob(fsys fs.FS, pattern string, m []string, firstSegment bool) (matches []string, err error) { matches = m patternStart := indexMeta(pattern) if patternStart == -1 { @@ -51,12 +61,16 @@ // pattern exist? // The pattern may contain escaped wildcard characters for an exact path match. path := unescapeMeta(pattern) - if exists(fsys, path) { + _, pathExists, pathErr := g.exists(fsys, path) + if pathErr != nil { + return nil, pathErr + } + + if pathExists { matches = append(matches, path) - return - } else { - return } + + return } dir := "." @@ -70,7 +84,7 @@ splitIdx = lastIndexSlash(pattern[:splitIdx]) } else { // otherwise, we have to handle the alts: - return globAlts(fsys, pattern, openingIdx, splitIdx, matches, firstSegment) + return g.globAlts(fsys, pattern, openingIdx, splitIdx, matches, firstSegment) } } @@ -82,16 +96,16 @@ // characters. They would be equal if they are both -1, which means `dir` // will be ".", and we know that doesn't have meta characters either. if splitIdx <= patternStart { - return globDir(fsys, dir, pattern, matches, firstSegment) + return g.globDir(fsys, dir, pattern, matches, firstSegment) } var dirs []string - dirs, err = doGlob(fsys, dir, matches, false) + dirs, err = g.doGlob(fsys, dir, matches, false) if err != nil { return } for _, d := range dirs { - matches, err = globDir(fsys, d, pattern, matches, firstSegment) + matches, err = g.globDir(fsys, d, pattern, matches, firstSegment) if err != nil { return } @@ -102,7 +116,7 @@ // handle alts in the glob pattern - `openingIdx` and `closingIdx` are the // indexes of `{` and `}`, respectively -func globAlts(fsys fs.FS, pattern string, openingIdx, closingIdx int, m []string, firstSegment bool) (matches []string, err error) { +func (g *glob) globAlts(fsys fs.FS, pattern string, openingIdx, closingIdx int, m []string, firstSegment bool) (matches []string, err error) { matches = m var dirs []string @@ -114,7 +128,7 @@ dirs = []string{""} } else { // our alts have a common prefix that we can process first - dirs, err = doGlob(fsys, pattern[:splitIdx], matches, false) + dirs, err = g.doGlob(fsys, pattern[:splitIdx], matches, false) if err != nil { return } @@ -135,7 +149,7 @@ } alt := buildAlt(d, pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) - matches, err = doGlob(fsys, alt, matches, firstSegment) + matches, err = g.doGlob(fsys, alt, matches, firstSegment) if err != nil { return } @@ -165,37 +179,49 @@ } // find files/subdirectories in the given `dir` that match `pattern` -func globDir(fsys fs.FS, dir, pattern string, matches []string, canMatchFiles bool) (m []string, e error) { +func (g *glob) globDir(fsys fs.FS, dir, pattern string, matches []string, canMatchFiles bool) (m []string, e error) { m = matches if pattern == "" { // pattern can be an empty string if the original pattern ended in a slash, // in which case, we should just return dir, but only if it actually exists // and it's a directory (or a symlink to a directory) - if isPathDir(fsys, dir) { + isDir, err := g.isPathDir(fsys, dir) + if err != nil { + return nil, err + } + if isDir { m = append(m, dir) } return } if pattern == "**" { - m = globDoubleStar(fsys, dir, m, canMatchFiles) - return + return g.globDoubleStar(fsys, dir, m, canMatchFiles) } dirs, err := fs.ReadDir(fsys, dir) if err != nil { - // ignore IO errors + if !errors.Is(err, fs.ErrNotExist) && g.failOnIOErrors { + return nil, err + } return } var matched bool for _, info := range dirs { name := info.Name() - if canMatchFiles || isDir(fsys, dir, name, info) { - matched, e = matchWithSeparator(pattern, name, '/', false) - if e != nil { - return + matched, e = matchWithSeparator(pattern, name, '/', false) + if e != nil { + return + } + if matched { + matched = canMatchFiles + if !matched { + matched, e = g.isDir(fsys, dir, name, info) + if e != nil { + return + } } if matched { m = append(m, path.Join(dir, name)) @@ -206,25 +232,34 @@ return } -func globDoubleStar(fsys fs.FS, dir string, matches []string, canMatchFiles bool) []string { +func (g *glob) globDoubleStar(fsys fs.FS, dir string, matches []string, canMatchFiles bool) ([]string, error) { dirs, err := fs.ReadDir(fsys, dir) if err != nil { - // ignore IO errors - return matches + if !errors.Is(err, fs.ErrNotExist) && g.failOnIOErrors { + return nil, err + } + return matches, nil } // `**` can match *this* dir, so add it matches = append(matches, dir) for _, info := range dirs { name := info.Name() - if isDir(fsys, dir, name, info) { - matches = globDoubleStar(fsys, path.Join(dir, name), matches, canMatchFiles) + isDir, err := g.isDir(fsys, dir, name, info) + if err != nil { + return nil, err + } + if isDir { + matches, err = g.globDoubleStar(fsys, path.Join(dir, name), matches, canMatchFiles) + if err != nil { + return nil, err + } } else if canMatchFiles { matches = append(matches, path.Join(dir, name)) } } - return matches + return matches, nil } // Returns true if the pattern has a doublestar in the middle of the pattern. @@ -302,26 +337,38 @@ } // Returns true if the path exists -func exists(fsys fs.FS, name string) bool { - if _, err := fs.Stat(fsys, name); err != nil { - return false +func (g *glob) exists(fsys fs.FS, name string) (fs.FileInfo, bool, error) { + // name might end in a slash, but Stat doesn't like that + namelen := len(name) + if namelen > 1 && name[namelen - 1] == '/' { + name = name[:namelen-1] + } + + info, err := fs.Stat(fsys, name) + if errors.Is(err, fs.ErrNotExist) { + return nil, false, nil } - return true + return info, err == nil, g.forwardErrIfFailOnIOErrors(err) } -// Returns true if the path is a directory, or a symlink to a directory -func isPathDir(fsys fs.FS, name string) bool { +// Returns true if the path exists and is a directory or a symlink to a +// directory +func (g *glob) isPathDir(fsys fs.FS, name string) (bool, error) { info, err := fs.Stat(fsys, name) if err != nil { - return false + if errors.Is(err, fs.ErrNotExist) { + return false, nil + } + return false, g.forwardErrIfFailOnIOErrors(err) } - return info.IsDir() + + return info.IsDir(), nil } // Returns whether or not the given DirEntry is a directory. If the DirEntry // represents a symbolic link, the link is followed by running fs.Stat() on // `path.Join(dir, name)` (if dir is "", name will be used without joining) -func isDir(fsys fs.FS, dir, name string, info fs.DirEntry) bool { +func (g *glob) isDir(fsys fs.FS, dir, name string, info fs.DirEntry) (bool, error) { if (info.Type() & fs.ModeSymlink) > 0 { p := name if dir != "" { @@ -329,11 +376,14 @@ } finfo, err := fs.Stat(fsys, p) if err != nil { - return false + if errors.Is(err, fs.ErrNotExist) { + return false, nil + } + return false, g.forwardErrIfFailOnIOErrors(err) } - return finfo.IsDir() + return finfo.IsDir(), nil } - return info.IsDir() + return info.IsDir(), nil } // Builds a string from an alt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go new/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go --- old/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go 1970-01-01 01:00:00.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go 2022-11-09 19:01:28.000000000 +0100 @@ -0,0 +1,48 @@ +package doublestar + +// glob is an internal type to store options during globbing. +type glob struct { + failOnIOErrors bool +} + +// GlobOption represents a setting that can be passed to Glob, GlobWalk, and +// FilepathGlob. +type GlobOption func(*glob) + +// Construct a new glob object with the given options +func newGlob(opts ...GlobOption) *glob { + g := &glob{} + for _, opt := range opts { + opt(g) + } + return g +} + +// 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 + } +} + +// 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 + } + return nil +} + +func (g *glob) GoString() string { + if g.failOnIOErrors { + return "opts: WithFailOnIOErrors" + } + return "opts: nil" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go new/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go --- old/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go 2022-11-09 19:01:28.000000000 +0100 @@ -1,6 +1,7 @@ package doublestar import ( + "errors" "io/fs" "path" "path/filepath" @@ -32,8 +33,13 @@ // path _is_ a directory, GlobWalk will not recurse into it. If the current // path is not a directory, the rest of the parent directory will be skipped. // -// GlobWalk ignores file system errors such as I/O errors reading directories. -// GlobWalk may return ErrBadPattern, reporting that the pattern is malformed. +// GlobWalk ignores file system errors such as I/O errors reading directories +// by default. GlobWalk may return ErrBadPattern, reporting that the pattern is +// malformed. +// +// To enable aborting on I/O errors, the WithFailOnIOErrors option can be +// passed. +// // Additionally, if the callback function `fn` returns an error, GlobWalk will // exit immediately and return that error. // @@ -42,32 +48,34 @@ // aren't sure if that's the case, you can use filepath.ToSlash() on your // pattern before calling GlobWalk(). // -func GlobWalk(fsys fs.FS, pattern string, fn GlobWalkFunc) 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 } - return doGlobWalk(fsys, pattern, true, fn) + + g := newGlob(opts...) + return g.doGlobWalk(fsys, pattern, true, fn) } // Actually execute GlobWalk -func doGlobWalk(fsys fs.FS, pattern string, firstSegment bool, fn GlobWalkFunc) error { +func (g *glob) doGlobWalk(fsys fs.FS, pattern string, firstSegment bool, fn GlobWalkFunc) error { patternStart := indexMeta(pattern) if patternStart == -1 { // pattern doesn't contain any meta characters - does a file matching the // pattern exist? // The pattern may contain escaped wildcard characters for an exact path match. path := unescapeMeta(pattern) - info, err := fs.Stat(fsys, path) - if err == nil { + info, pathExists, err := g.exists(fsys, path) + if pathExists { err = fn(path, dirEntryFromFileInfo(info)) if err == SkipDir { err = nil } - return err - } else { - // ignore IO errors - return nil } + return err } dir := "." @@ -81,7 +89,7 @@ splitIdx = lastIndexSlash(pattern[:splitIdx]) } else { // otherwise, we have to handle the alts: - return globAltsWalk(fsys, pattern, openingIdx, splitIdx, firstSegment, fn) + return g.globAltsWalk(fsys, pattern, openingIdx, splitIdx, firstSegment, fn) } } @@ -93,11 +101,11 @@ // characters. They would be equal if they are both -1, which means `dir` // will be ".", and we know that doesn't have meta characters either. if splitIdx <= patternStart { - return globDirWalk(fsys, dir, pattern, firstSegment, fn) + return g.globDirWalk(fsys, dir, pattern, firstSegment, fn) } - return doGlobWalk(fsys, dir, false, func(p string, d fs.DirEntry) error { - if err := globDirWalk(fsys, p, pattern, firstSegment, fn); err != nil { + return g.doGlobWalk(fsys, dir, false, func(p string, d fs.DirEntry) error { + if err := g.globDirWalk(fsys, p, pattern, firstSegment, fn); err != nil { return err } return nil @@ -106,22 +114,22 @@ // handle alts in the glob pattern - `openingIdx` and `closingIdx` are the // indexes of `{` and `}`, respectively -func globAltsWalk(fsys fs.FS, pattern string, openingIdx, closingIdx int, firstSegment bool, fn GlobWalkFunc) (err error) { +func (g *glob) globAltsWalk(fsys fs.FS, pattern string, openingIdx, closingIdx int, firstSegment bool, fn GlobWalkFunc) (err error) { var matches []DirEntryWithFullPath startIdx := 0 afterIdx := closingIdx + 1 splitIdx := lastIndexSlashOrAlt(pattern[:openingIdx]) if splitIdx == -1 || pattern[splitIdx] == '}' { // no common prefix - matches, err = doGlobAltsWalk(fsys, "", pattern, startIdx, openingIdx, closingIdx, afterIdx, firstSegment, matches) + matches, err = g.doGlobAltsWalk(fsys, "", pattern, startIdx, openingIdx, closingIdx, afterIdx, firstSegment, matches) if err != nil { return } } else { // our alts have a common prefix that we can process first startIdx = splitIdx + 1 - err = doGlobWalk(fsys, pattern[:splitIdx], false, func(p string, d fs.DirEntry) (e error) { - matches, e = doGlobAltsWalk(fsys, p, pattern, startIdx, openingIdx, closingIdx, afterIdx, firstSegment, matches) + err = g.doGlobWalk(fsys, pattern[:splitIdx], false, func(p string, d fs.DirEntry) (e error) { + matches, e = g.doGlobAltsWalk(fsys, p, pattern, startIdx, openingIdx, closingIdx, afterIdx, firstSegment, matches) return e }) if err != nil { @@ -151,7 +159,11 @@ } if err = fn(m.Path, m.Entry); err != nil { if err == SkipDir { - if isDir(fsys, "", m.Path, m.Entry) { + isDir, err := g.isDir(fsys, "", m.Path, m.Entry) + if err != nil { + return err + } + if isDir { // append a slash to guarantee `skip` will be treated as a parent dir skip = m.Path + "/" } else { @@ -170,7 +182,7 @@ } // runs actual matching for alts -func doGlobAltsWalk(fsys fs.FS, d, pattern string, startIdx, openingIdx, closingIdx, afterIdx int, firstSegment bool, m []DirEntryWithFullPath) (matches []DirEntryWithFullPath, err error) { +func (g *glob) doGlobAltsWalk(fsys fs.FS, d, pattern string, startIdx, openingIdx, closingIdx, afterIdx int, firstSegment bool, m []DirEntryWithFullPath) (matches []DirEntryWithFullPath, err error) { matches = m matchesLen := len(m) patIdx := openingIdx + 1 @@ -183,7 +195,7 @@ } alt := buildAlt(d, pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) - err = doGlobWalk(fsys, alt, firstSegment, func(p string, d fs.DirEntry) error { + err = g.doGlobWalk(fsys, alt, firstSegment, func(p string, d fs.DirEntry) error { // insertion sort, ignoring dups insertIdx := matchesLen for insertIdx > 0 && matches[insertIdx-1].Path > p { @@ -215,13 +227,16 @@ return } -func globDirWalk(fsys fs.FS, dir, pattern string, canMatchFiles bool, fn GlobWalkFunc) (e error) { +func (g *glob) globDirWalk(fsys fs.FS, dir, pattern string, canMatchFiles bool, fn GlobWalkFunc) (e error) { if pattern == "" { // pattern can be an empty string if the original pattern ended in a slash, // in which case, we should just return dir, but only if it actually exists // and it's a directory (or a symlink to a directory) info, err := fs.Stat(fsys, dir) - if err != nil || !info.IsDir() { + if err != nil { + return g.forwardErrIfFailOnIOErrors(err) + } + if !info.IsDir() { return nil } @@ -234,8 +249,11 @@ if pattern == "**" { // `**` can match *this* dir - info, err := fs.Stat(fsys, dir) - if err != nil || !info.IsDir() { + info, dirExists, err := g.exists(fsys, dir) + if err != nil { + return g.forwardErrIfFailOnIOErrors(err) + } + if !dirExists || !info.IsDir() { return nil } if e = fn(dir, dirEntryFromFileInfo(info)); e != nil { @@ -244,22 +262,31 @@ } return } - return globDoubleStarWalk(fsys, dir, canMatchFiles, fn) + return g.globDoubleStarWalk(fsys, dir, canMatchFiles, fn) } dirs, err := fs.ReadDir(fsys, dir) if err != nil { - // ignore IO errors - return nil + if errors.Is(err, fs.ErrNotExist) { + return + } + return g.forwardErrIfFailOnIOErrors(err) } var matched bool for _, info := range dirs { name := info.Name() - if canMatchFiles || isDir(fsys, dir, name, info) { - matched, e = matchWithSeparator(pattern, name, '/', false) - if e != nil { - return + matched, e = matchWithSeparator(pattern, name, '/', false) + if e != nil { + return + } + if matched { + matched = canMatchFiles + if !matched { + matched, e = g.isDir(fsys, dir, name, info) + if e != nil { + return e + } } if matched { if e = fn(path.Join(dir, name), info); e != nil { @@ -276,17 +303,24 @@ } // recursively walk files/directories in a directory -func globDoubleStarWalk(fsys fs.FS, dir string, canMatchFiles bool, fn GlobWalkFunc) (e error) { +func (g *glob) globDoubleStarWalk(fsys fs.FS, dir string, canMatchFiles bool, fn GlobWalkFunc) (e error) { dirs, err := fs.ReadDir(fsys, dir) if err != nil { - // ignore IO errors - return + if errors.Is(err, fs.ErrNotExist) { + return + } + return g.forwardErrIfFailOnIOErrors(err) } // `**` can match *this* dir, so add it for _, info := range dirs { name := info.Name() - if isDir(fsys, dir, name, info) { + isDir, err := g.isDir(fsys, dir, name, info) + if err != nil { + return err + } + + if isDir { p := path.Join(dir, name) if e = fn(p, info); e != nil { if e == SkipDir { @@ -295,7 +329,7 @@ } return } - if e = globDoubleStarWalk(fsys, p, canMatchFiles, fn); e != nil { + if e = g.globDoubleStarWalk(fsys, p, canMatchFiles, fn); e != nil { return } } else if canMatchFiles { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/match.go new/vendor/github.com/bmatcuk/doublestar/v4/match.go --- old/vendor/github.com/bmatcuk/doublestar/v4/match.go 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/match.go 2022-11-09 19:01:28.000000000 +0100 @@ -46,6 +46,9 @@ // is PathMatch(). Alternatively, you can run filepath.ToSlash() on both // pattern and name and then use this function. // +// 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) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/bmatcuk/doublestar/v4/utils.go new/vendor/github.com/bmatcuk/doublestar/v4/utils.go --- old/vendor/github.com/bmatcuk/doublestar/v4/utils.go 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/github.com/bmatcuk/doublestar/v4/utils.go 2022-11-09 19:01:28.000000000 +0100 @@ -62,25 +62,32 @@ // pattern may describe hierarchical names such as usr/*/bin/ed. // // FilepathGlob ignores file system errors such as I/O errors reading -// directories. The only possible returned error is ErrBadPattern, reporting -// that the pattern is malformed. +// directories by default. The only possible returned error is ErrBadPattern, +// reporting that the pattern is malformed. +// +// To enable aborting on I/O errors, the WithFailOnIOErrors option can be +// passed. // // Note: FilepathGlob is a convenience function that is meant as a drop-in // replacement for `path/filepath.Glob()` for users who don't need the // complication of io/fs. Basically, it: -// * Runs `filepath.Clean()` and `ToSlash()` on the pattern -// * Runs `SplitPattern()` to get a base path and a pattern to Glob -// * Creates an FS object from the base path and `Glob()s` on the pattern -// * Joins the base path with all of the matches from `Glob()` +// - Runs `filepath.Clean()` and `ToSlash()` on the pattern +// - Runs `SplitPattern()` to get a base path and a pattern to Glob +// - Creates an FS object from the base path and `Glob()s` on the pattern +// - Joins the base path with all of the matches from `Glob()` // // Returned paths will use the system's path separator, just like // `filepath.Glob()`. -func FilepathGlob(pattern string) (matches []string, err error) { +// +// Note: the returned error doublestar.ErrBadPattern is not equal to +// filepath.ErrBadPattern. +// +func FilepathGlob(pattern string, opts ...GlobOption) (matches []string, err error) { pattern = filepath.Clean(pattern) pattern = filepath.ToSlash(pattern) base, f := SplitPattern(pattern) fs := os.DirFS(base) - if matches, err = Glob(fs, f); err != nil { + if matches, err = Glob(fs, f, opts...); err != nil { return nil, err } for i := range matches { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/modules.txt new/vendor/modules.txt --- old/vendor/modules.txt 2022-11-02 11:28:27.000000000 +0100 +++ new/vendor/modules.txt 2022-11-09 19:01:28.000000000 +0100 @@ -178,7 +178,7 @@ ## explicit github.com/aymerick/douceur/css github.com/aymerick/douceur/parser -# github.com/bmatcuk/doublestar/v4 v4.2.0 +# github.com/bmatcuk/doublestar/v4 v4.3.1 ## explicit; go 1.16 github.com/bmatcuk/doublestar/v4 # github.com/bradenhilton/cityhash v1.0.0 @@ -379,7 +379,7 @@ # github.com/mitchellh/reflectwalk v1.0.2 ## explicit github.com/mitchellh/reflectwalk -# github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 +# github.com/muesli/ansi v0.0.0-20221106050444-61f0cd9a192a ## explicit; go 1.17 github.com/muesli/ansi github.com/muesli/ansi/compressor @@ -540,7 +540,7 @@ golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/knownhosts -# golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f +# golang.org/x/exp v0.0.0-20221106115401-f9659909a136 ## explicit; go 1.18 golang.org/x/exp/constraints golang.org/x/exp/maps