Skip to content

Commit

Permalink
fix: diff hidden but non-ignored files when walking directories
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics authored and Wilfred committed Apr 1, 2024
1 parent 1f79d16 commit 573d607
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
9 changes: 5 additions & 4 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 573d607

Please sign in to comment.