Skip to content

Commit 8f62f0a

Browse files
committed
ignore dirs
1 parent 5a99560 commit 8f62f0a

5 files changed

Lines changed: 25 additions & 41 deletions

File tree

src/config.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub struct Config {
2222
#[serde(default = "default_cache_directory")]
2323
pub cache_directory: String,
2424

25-
#[serde(default = "default_ignore_globs")]
26-
pub ignore_globs: Vec<String>,
25+
#[serde(default = "default_ignore_dirs")]
26+
pub ignore_dirs: Vec<String>,
2727
}
2828

2929
#[allow(dead_code)]
@@ -60,20 +60,20 @@ fn vendored_gems_path() -> String {
6060
"vendored/".to_string()
6161
}
6262

63-
fn default_ignore_globs() -> Vec<String> {
63+
fn default_ignore_dirs() -> Vec<String> {
6464
vec![
65-
"/.cursor".to_owned(),
66-
"/.git".to_owned(),
67-
"/.idea".to_owned(),
68-
"/.vscode".to_owned(),
69-
"/.yarn".to_owned(),
70-
"/ar_doc".to_owned(),
71-
"/db".to_owned(),
72-
"/helm".to_owned(),
73-
"/log".to_owned(),
74-
"/node_modules".to_owned(),
75-
"/sorbet".to_owned(),
76-
"/tmp".to_owned(),
65+
".cursor".to_owned(),
66+
".git".to_owned(),
67+
".idea".to_owned(),
68+
".vscode".to_owned(),
69+
".yarn".to_owned(),
70+
"ar_doc".to_owned(),
71+
"db".to_owned(),
72+
"helm".to_owned(),
73+
"log".to_owned(),
74+
"node_modules".to_owned(),
75+
"sorbet".to_owned(),
76+
"tmp".to_owned(),
7777
]
7878
}
7979

src/ignore.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub mod cache;
22
pub(crate) mod common_test;
33
pub mod config;
4-
pub(crate) mod ignore;
54
pub mod ownership;
65
pub(crate) mod project;
76
pub mod project_builder;

src/ownership/for_file_fast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ mod tests {
303303
unowned_globs: vec![],
304304
vendored_gems_path: vendored_path.to_string(),
305305
cache_directory: "tmp/cache/codeowners".to_string(),
306-
ignore_globs: vec![],
306+
ignore_dirs: vec![],
307307
}
308308
}
309309

src/project_builder.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ impl<'a> ProjectBuilder<'a> {
5555
builder.hidden(false);
5656
builder.follow_links(false);
5757
// Prune traversal early: skip heavy and irrelevant directories
58-
let ignore_globs = self.config.ignore_globs.clone();
58+
let ignore_dirs = self.config.ignore_dirs.clone();
5959
let base_path = self.base_path.clone();
6060

6161
builder.filter_entry(move |entry: &DirEntry| {
62-
if let Ok(relative_path) = entry.path().strip_prefix(&base_path) {
63-
if let Some(relative_path_str) = relative_path.to_str() {
64-
if crate::ignore::matches_path(&ignore_globs, relative_path_str) {
65-
return false;
62+
let path = entry.path();
63+
let file_name = entry.file_name().to_str().unwrap_or("");
64+
if let Some(ft) = entry.file_type() {
65+
if ft.is_dir() {
66+
if let Ok(rel) = path.strip_prefix(&base_path) {
67+
if rel.components().count() == 1 && ignore_dirs.iter().any(|d| *d == file_name) {
68+
return false;
69+
}
6670
}
6771
}
6872
}

0 commit comments

Comments
 (0)