mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Look for .ignore files in subfolders of watched paths
This commit is contained in:
parent
0175e071e1
commit
2d29a7d7c4
1 changed files with 19 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
extern crate globset;
|
||||
extern crate walkdir;
|
||||
|
||||
use globset::{GlobBuilder, GlobSet, GlobSetBuilder};
|
||||
use std::collections::HashSet;
|
||||
|
@ -6,6 +7,7 @@ use std::fs;
|
|||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub struct Ignore {
|
||||
files: Vec<IgnoreFile>,
|
||||
|
@ -48,6 +50,7 @@ pub fn load(paths: &[PathBuf]) -> Ignore {
|
|||
for path in paths {
|
||||
let mut p = path.to_owned();
|
||||
|
||||
// walk up to root
|
||||
loop {
|
||||
if !checked_dirs.contains(&p) {
|
||||
checked_dirs.insert(p.clone());
|
||||
|
@ -69,6 +72,22 @@ pub fn load(paths: &[PathBuf]) -> Ignore {
|
|||
|
||||
p.pop();
|
||||
}
|
||||
|
||||
//also look in subfolders
|
||||
for entry in WalkDir::new(path)
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|e| e.file_type().is_file())
|
||||
.filter(|e| e.file_name() == ".ignore")
|
||||
{
|
||||
let ignore_path = entry.path();
|
||||
if let Ok(f) = IgnoreFile::new(&ignore_path) {
|
||||
debug!("Loaded {:?}", ignore_path);
|
||||
files.push(f);
|
||||
} else {
|
||||
debug!("Unable to load {:?}", ignore_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ignore::new(files)
|
||||
|
|
Loading…
Reference in a new issue