Skip to content

Commit

Permalink
Skip dirs specified in gitignore (#574)
Browse files Browse the repository at this point in the history
Take ignored dirs into consideration when calculating diff

Co-authored-by: Nimrod <[email protected]>
  • Loading branch information
nimrodkor and Nimrod authored Nov 24, 2023
1 parent 1c0074f commit e9a8fda
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/*.rs.bk
perf.data*
flamegraph.svg
.idea

sample_files/compare.result

Expand Down
141 changes: 122 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mimalloc = { version = "0.1.28", default-features = false }
# large textual files, as discussed in #297.
libmimalloc-sys = "=0.1.24"
radix-heap = "0.4.2"
walkdir = "2.3.3"
ignore = "0.3.1"
const_format = "0.2.22"
owo-colors = "3.5.0"
wu-diff = "0.1.2"
Expand Down
6 changes: 3 additions & 3 deletions src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{
path::{Path, PathBuf},
};

use ignore::Walk;
use rustc_hash::FxHashSet;
use walkdir::WalkDir;

use crate::exit_codes::EXIT_BAD_ARGUMENTS;
use crate::options::FileArgument;
Expand Down Expand Up @@ -235,10 +235,10 @@ 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> {
WalkDir::new(dir)
Walk::new(dir)
.into_iter()
.filter_map(Result::ok)
.map(|entry| entry.into_path())
.map(|entry| Path::new(entry.path()).to_owned())
.filter(|path| !path.is_dir())
.map(|path| path.strip_prefix(dir).unwrap().to_path_buf())
.collect()
Expand Down

0 comments on commit e9a8fda

Please sign in to comment.