Make a leading **/ in an exclude pattern match at the top level (closes #303)
check / check (push) Waiting to run
check / check (push) Waiting to run
An unanchored exclude pattern such as **/node_modules or **/*.pyc needed a / before the name, so it excluded sub/node_modules and sub/y.pyc but backed up node_modules/ and x.pyc directly under the snapshot path. An unanchored pattern already matches at every depth, so the leading **/ is now dropped when the pattern is compiled and, as in gitignore, the pattern matches the top level too. Judgement call: an anchored /**/x is left as it was; the issue covers patterns that start with **/. Model: opus-5-5
This commit was merged in pull request #335.
This commit is contained in:
@@ -2018,6 +2018,14 @@ func compileExcludePatterns(patterns []string) []compiledPattern {
|
||||
// Remove trailing slash if present (directory indicator)
|
||||
pattern = strings.TrimSuffix(pattern, "/")
|
||||
|
||||
// A leading "**/" demands a "/" before the name and so misses an
|
||||
// entry directly under the source path. An unanchored pattern
|
||||
// already matches at every depth, so drop the prefix: as in
|
||||
// gitignore, "**/x" then also matches a top-level "x".
|
||||
if !anchored {
|
||||
pattern = strings.TrimPrefix(pattern, "**/")
|
||||
}
|
||||
|
||||
// Compile the glob pattern
|
||||
// For patterns without path separators, we need to match them as components
|
||||
// e.g., ".git" should match ".git" anywhere in the path
|
||||
|
||||
Reference in New Issue
Block a user