diff options
author | Alexis (Poliorcetics) Bourget <ab_jujutsu@poliorcetiq.eu> | 2024-03-01 22:22:25 +0100 |
---|---|---|
committer | Wilfred Hughes <me@wilfred.me.uk> | 2024-04-01 08:32:46 -0700 |
commit | 573d60705182507304445ff70cb21f393e923038 (patch) | |
tree | ffeb3a7a007b441384b9d9a1c4582206dd75fe74 | |
parent | 1f79d16606ff48d50446386adeca6c221b3b8f3c (diff) |
fix: diff hidden but non-ignored files when walking directories
-rw-r--r-- | src/files.rs | 6 | ||||
-rw-r--r-- | tests/cli.rs | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/files.rs b/src/files.rs index 7501647bc..940baef8d 100644 --- a/src/files.rs +++ b/src/files.rs @@ -7,7 +7,7 @@ use std::{ path::{Path, PathBuf}, }; -use ignore::Walk; +use ignore::WalkBuilder; use rustc_hash::FxHashSet; use crate::exit_codes::EXIT_BAD_ARGUMENTS; @@ -228,7 +228,9 @@ pub(crate) fn guess_content(bytes: &[u8]) -> ProbableFileKind { /// All the files in `dir`, including subdirectories. fn relative_file_paths_in_dir(dir: &Path) -> Vec<PathBuf> { - Walk::new(dir) + WalkBuilder::new(dir) + .hidden(false) + .build() .filter_map(Result::ok) .map(|entry| Path::new(entry.path()).to_owned()) .filter(|path| !path.is_dir()) diff --git a/tests/cli.rs b/tests/cli.rs index b7c1db4df..046d891f8 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -253,9 +253,10 @@ fn walk_hidden_items() { cmd.args(["sample_files/hidden-before", "sample_files/hidden-after"]); - let predicate_fn = predicate::str::contains(".hidden/doc.txt") - .and(predicate::str::contains(".hidden.txt")) - .and(predicate::str::contains("before")) - .and(predicate::str::contains("after")); + let predicate_fn = + predicate::str::contains(format!(".hidden{}doc.txt", std::path::MAIN_SEPARATOR)) + .and(predicate::str::contains(".hidden.txt")) + .and(predicate::str::contains("before")) + .and(predicate::str::contains("after")); cmd.assert().stdout(predicate_fn); } |