Fix the bugs

This commit is contained in:
Kirill Bulatov 2023-11-13 23:18:24 +02:00
parent 126e4cce8f
commit b8be720490
3 changed files with 50 additions and 69 deletions

View file

@ -1,5 +1,5 @@
use ignore::gitignore::Gitignore;
use std::{path::Path, sync::Arc};
use std::{ffi::OsStr, path::Path, sync::Arc};
pub enum IgnoreStack {
None,
@ -30,4 +30,23 @@ impl IgnoreStack {
}),
}
}
pub fn is_abs_path_ignored(&self, abs_path: &Path, is_dir: bool) -> bool {
if is_dir && abs_path.file_name() == Some(OsStr::new(".git")) {
return true;
}
match self {
Self::None => false,
Self::All => true,
Self::Some {
abs_base_path,
ignore,
parent: prev,
} => match ignore.matched(abs_path.strip_prefix(abs_base_path).unwrap(), is_dir) {
ignore::Match::None => prev.is_abs_path_ignored(abs_path, is_dir),
ignore::Match::Ignore(_) => true,
ignore::Match::Whitelist(_) => false,
},
}
}
}