ignore: fix has_any_ignore_rules for explicit ignores

When building a ignore::WalkBuilder by disabling all standard filters
and adding a custom global ignore file, the ignore file is not used. Example:

    let mut walker = ignore::WalkBuilder::new(dir);
    walker.standard_filters(false);
    walker.add_ignore(myfile);

This makes it impossible to use the ignore crate to walk a directory
with only custom ignore files. Very similar to issue #800 (fixed in
b71a110).

PR #988
This commit is contained in:
phiresky
2018-07-21 19:26:54 +02:00
committed by Andrew Gallant
parent d11a3b3377
commit aa2ce39d14
2 changed files with 20 additions and 0 deletions

View File

@@ -266,9 +266,11 @@ impl Ignore {
fn has_any_ignore_rules(&self) -> bool {
let opts = self.0.opts;
let has_custom_ignore_files = !self.0.custom_ignore_filenames.is_empty();
let has_explicit_ignores = !self.0.explicit_ignores.is_empty();
opts.ignore || opts.git_global || opts.git_ignore
|| opts.git_exclude || has_custom_ignore_files
|| has_explicit_ignores
}
/// Returns a match indicating whether the given file path should be