Skip to content

Commit

Permalink
fix: skipping children expansion when ignore_glob ends with /*
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed Mar 11, 2024
1 parent 1185e0d commit 815331a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/fs/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ impl FileFilter {
}
}

/// checks if a dirname, when appended with a `/` matches any
/// of the ignore patterns provided as argument.
///
/// this only exists since when creating the patterns, any glob
/// that ends with `/` or `/*` will keep the `/` on the pattern,
/// and when listing directories, we display them without any `/`
pub fn should_skip_expansion(&self, dirname: &str) -> bool {
let dirname_with_slash = format!("{dirname}/");
self.ignore_patterns.is_ignored(&dirname_with_slash)
}

/// Remove every file in the given vector that does *not* pass the
/// filter predicate for file names specified on the command-line.
///
Expand Down
6 changes: 5 additions & 1 deletion src/output/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ impl<'a> Render<'a> {

let mut dir = None;
if let Some(r) = self.recurse {
if file.is_directory() && r.tree && !r.is_too_deep(depth.0) {
if file.is_directory()
&& r.tree
&& !r.is_too_deep(depth.0)
&& !self.filter.should_skip_expansion(&file.name)
{
trace!("matching on to_dir");
match file.to_dir() {
Ok(d) => {
Expand Down

0 comments on commit 815331a

Please sign in to comment.