Skip to content

Commit d1449f7

Browse files
karthiknadigCopilot
andcommitted
fix: detect brace-expanded recursive globs (PR #495)
Classify globstar alternatives after brace expansion and cover the recursive brace case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7e05ed2 commit d1449f7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

crates/pet-fs/src/glob.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub fn is_glob_pattern(path: &str) -> bool {
2121

2222
/// Returns true when a glob can traverse an unbounded number of path components.
2323
pub fn is_recursive_glob_pattern(path: &str) -> bool {
24-
path.split(['/', '\\']).any(|segment| segment == "**")
24+
expand_braces(path)
25+
.iter()
26+
.any(|pattern| pattern.split(['/', '\\']).any(|segment| segment == "**"))
2527
}
2628

2729
/// Checks if a string contains a valid brace expansion pattern `{a,b}`.
@@ -215,6 +217,7 @@ mod tests {
215217
assert!(!is_recursive_glob_pattern("*/.venv"));
216218
assert!(!is_recursive_glob_pattern("foo**bar/.venv"));
217219
assert!(is_recursive_glob_pattern("C:\\workspace\\**\\.venv"));
220+
assert!(is_recursive_glob_pattern("{foo,**}/.venv"));
218221
}
219222
#[test]
220223
fn test_is_glob_pattern_with_question_mark() {

0 commit comments

Comments
 (0)