mirror of
https://github.com/watchexec/watchexec.git
synced 2024-10-01 07:31:35 +02:00
fix the ignore path handling to match the README by ignoring everything
below a directory
This commit is contained in:
parent
798fd3c0bd
commit
1c6f5fab89
@ -31,6 +31,9 @@ impl NotificationFilter {
|
|||||||
if ignore_path.is_relative() && !i.starts_with('*') {
|
if ignore_path.is_relative() && !i.starts_with('*') {
|
||||||
ignore_path = Path::new("**").join(&ignore_path);
|
ignore_path = Path::new("**").join(&ignore_path);
|
||||||
}
|
}
|
||||||
|
if !i.ends_with('*') {
|
||||||
|
ignore_path = ignore_path.join("**");
|
||||||
|
}
|
||||||
let pattern = ignore_path
|
let pattern = ignore_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("corrupted memory (string -> path -> string)");
|
.expect("corrupted memory (string -> path -> string)");
|
||||||
@ -137,4 +140,18 @@ mod tests {
|
|||||||
assert!(filter.is_excluded(Path::new("Cargo.toml")));
|
assert!(filter.is_excluded(Path::new("Cargo.toml")));
|
||||||
assert!(filter.is_excluded(Path::new("README.md")));
|
assert!(filter.is_excluded(Path::new("README.md")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_recursive_directory_ignore() {
|
||||||
|
let ignores = &["target".into()];
|
||||||
|
let filter = NotificationFilter::new(&[], ignores, gitignore::load(&[]), ignore::load(&[]))
|
||||||
|
.expect("test filter errors");
|
||||||
|
|
||||||
|
assert!(filter.is_excluded(Path::new("target")));
|
||||||
|
// Make sure that sub-directories/-files are recursively ignored.
|
||||||
|
assert!(filter.is_excluded(Path::new("target/rls")));
|
||||||
|
assert!(filter.is_excluded(Path::new("target/rls/debug")));
|
||||||
|
assert!(!filter.is_excluded(Path::new("hello.rs")));
|
||||||
|
assert!(!filter.is_excluded(Path::new("Cargo.toml")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user