-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Not Ignoring Subdirectories in directories #865
Comments
Can you try out older versions of eza and see if you can find out where it broke, or e.g. do a git bisect to find what commit broke it? |
I have tried various versions even from 2021, nothing seems to work. (Of course not eza but exa what I was using earlier) What I observed is it takes value for
It won't work as apposed to:
Without forward slash. I was using exa before. Trying older versions making me question myself that was it really working that way. 😂 |
I was looking into this as it seemed not so complicated to me, and I found out that currently, patterns for IgnorePatterns are built with
notice that it contains the last forward slash, this is true using The problem is that when we call Here is a code snippet that I used to test this: fn main() {
let pattern = glob::Pattern::new("node_modules/*").unwrap();
let is_match = pattern.matches("node_modules");
println!("{pattern:?}");
println!("{is_match:?}");
} I'm not sure how to fix this issue but I figured it would be good to share what I found here. I'm totally willing to fix this if we find a way to do this |
This commit removes trailing `/` or `/*` to fix eza-community#865. Where globs ending with those patterns would not match any directory, as the default listing doesn't include an ending `/`.
Ok, I went in the wrong direction with the first fix, and spent the last 2 days exploring how to solve this in a good way. As mentioned above, when finishing a glob with Inside of this is how I tested: // [SNIP]
fn add_files_to_table<'dir>(
// ...
) {
if let Some(r) = self.recurse {
if file.is_directory()
&& r.tree
&& !r.is_too_deep(depth.0)
&& !self.filter.should_skip_expansion(&file.name)
{
// ...
}
}
} /// 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)
} I wanted to discuss how we could possibly make this change in a way that adheres to your vision of how eza should be, and if this is even a thing you want to support. Personally, I don't think adding a '/' to check if it matches with a glob that ends with '/' or '/*' is any good. But by only removing the slash of the glob as I did before, we can only ignore the glob altogether, so the only straightforward way I found was doing this check. What do you think? |
Resolves: eza-community#865 `--ignore-glob` previously matched against file names, but now matches against file paths. This allows users to ignore directory contents without ignoring the directory itself.
Hello, everyone!
I'm loving this tool so much; I use the tree flag to show current directories & subdirectories. However, one thing I don't want it to show is what's inside the
node_modules
directory.This is the command that I'm using for my
ls
alias:If I remember correctly, this command used to work and would behave as expected (i.e., it should show
node_modules
's existence but not its subdirectories), but now it doesn't after I updated my system.Operating system: ArchLinux aarch64
eza: v0.18.4 [+git]
The text was updated successfully, but these errors were encountered: