Ignore .git directories

This commit is contained in:
Max Brunsfeld 2021-04-26 15:46:06 -07:00
parent e7c594262f
commit 733dc15c32
2 changed files with 7 additions and 2 deletions

View File

@ -1423,10 +1423,12 @@ mod tests {
app.read(|ctx| tree.read(ctx).next_scan_complete()).await;
app.read(|ctx| {
let tree = tree.read(ctx);
let dot_git = tree.entry_for_path(".git").unwrap();
let tracked = tree.entry_for_path("tracked-dir/tracked-file2").unwrap();
let ignored = tree.entry_for_path("ignored-dir/ignored-file2").unwrap();
assert_eq!(tracked.is_ignored(), false);
assert_eq!(ignored.is_ignored(), true);
assert_eq!(dot_git.is_ignored(), true);
});
});
}

View File

@ -1,6 +1,5 @@
use std::{path::Path, sync::Arc};
use ignore::gitignore::Gitignore;
use std::{ffi::OsStr, path::Path, sync::Arc};
pub enum IgnoreStack {
None,
@ -37,6 +36,10 @@ impl IgnoreStack {
}
pub fn is_path_ignored(&self, path: &Path, is_dir: bool) -> bool {
if is_dir && path.file_name() == Some(OsStr::new(".git")) {
return true;
}
match self {
Self::None => false,
Self::All => true,