mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Look for .ignore files in subfolders of watched paths
This commit is contained in:
parent
0175e071e1
commit
2d29a7d7c4
@ -1,4 +1,5 @@
|
|||||||
extern crate globset;
|
extern crate globset;
|
||||||
|
extern crate walkdir;
|
||||||
|
|
||||||
use globset::{GlobBuilder, GlobSet, GlobSetBuilder};
|
use globset::{GlobBuilder, GlobSet, GlobSetBuilder};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@ -6,6 +7,7 @@ use std::fs;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
pub struct Ignore {
|
pub struct Ignore {
|
||||||
files: Vec<IgnoreFile>,
|
files: Vec<IgnoreFile>,
|
||||||
@ -48,6 +50,7 @@ pub fn load(paths: &[PathBuf]) -> Ignore {
|
|||||||
for path in paths {
|
for path in paths {
|
||||||
let mut p = path.to_owned();
|
let mut p = path.to_owned();
|
||||||
|
|
||||||
|
// walk up to root
|
||||||
loop {
|
loop {
|
||||||
if !checked_dirs.contains(&p) {
|
if !checked_dirs.contains(&p) {
|
||||||
checked_dirs.insert(p.clone());
|
checked_dirs.insert(p.clone());
|
||||||
@ -69,6 +72,22 @@ pub fn load(paths: &[PathBuf]) -> Ignore {
|
|||||||
|
|
||||||
p.pop();
|
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)
|
Ignore::new(files)
|
||||||
|
Loading…
Reference in New Issue
Block a user