Skip dirs specified in gitignore (#574)

Take ignored dirs into consideration when calculating diff

Co-authored-by: Nimrod <nimrod@getbaz.com>
pull/579/head^2
Nimrod Kor 2023-11-24 02:48:55 +07:00 committed by GitHub
parent 1c0074f7ba
commit e9a8fda9cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 127 additions and 23 deletions

1
.gitignore vendored

@ -2,6 +2,7 @@
**/*.rs.bk
perf.data*
flamegraph.svg
.idea
sample_files/compare.result

141
Cargo.lock generated

@ -13,6 +13,15 @@ dependencies = [
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
dependencies = [
"memchr",
]
[[package]]
name = "aho-corasick"
version = "1.1.2"
@ -71,7 +80,7 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"lazy_static 1.4.0",
"memchr",
"regex-automata 0.1.10",
]
@ -113,7 +122,7 @@ dependencies = [
"bitflags 1.3.2",
"clap_lex",
"indexmap",
"lazy_static",
"lazy_static 1.4.0",
"strsim",
"termcolor",
"terminal_size",
@ -149,6 +158,12 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "crossbeam"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be"
[[package]]
name = "crossbeam-channel"
version = "0.5.8"
@ -179,7 +194,7 @@ dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"lazy_static",
"lazy_static 1.4.0",
"memoffset",
"scopeguard",
]
@ -191,7 +206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [
"cfg-if",
"lazy_static",
"lazy_static 1.4.0",
]
[[package]]
@ -254,13 +269,14 @@ dependencies = [
"glob",
"hashbrown 0.12.3",
"humansize",
"ignore",
"is-terminal",
"itertools 0.11.0",
"lazy_static",
"lazy_static 1.4.0",
"libc",
"libmimalloc-sys",
"line-numbers",
"log",
"log 0.4.17",
"memchr",
"mimalloc",
"owo-colors",
@ -269,7 +285,7 @@ dependencies = [
"pretty_env_logger",
"radix-heap",
"rayon",
"regex",
"regex 1.9.4",
"rustc-hash",
"serde",
"serde_json",
@ -280,7 +296,6 @@ dependencies = [
"typed-arena",
"unicode-width",
"version_check",
"walkdir",
"wu-diff",
]
@ -304,8 +319,8 @@ checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"log 0.4.17",
"regex 1.9.4",
"termcolor",
]
@ -357,6 +372,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "globset"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "464627f948c3190ae3d04b1bc6d7dca2f785bda0ac01278e6db129ad383dbeb6"
dependencies = [
"aho-corasick 0.6.10",
"fnv",
"log 0.3.9",
"memchr",
"regex 0.2.11",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
@ -408,6 +436,23 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "ignore"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2f0238094bd1b41800fb6eb9b16fdd5e9832ed6053ed91409f0cd5bf28dcfd"
dependencies = [
"crossbeam",
"globset",
"lazy_static 0.2.11",
"log 0.3.9",
"memchr",
"regex 0.2.11",
"same-file",
"thread_local",
"walkdir",
]
[[package]]
name = "indexmap"
version = "1.7.0"
@ -465,6 +510,12 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "lazy_static"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -514,6 +565,15 @@ dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
dependencies = [
"log 0.4.17",
]
[[package]]
name = "log"
version = "0.4.17"
@ -560,7 +620,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [
"libc",
"log",
"log 0.4.17",
"wasi",
"windows-sys 0.42.0",
]
@ -671,7 +731,7 @@ dependencies = [
"itertools 0.10.3",
"normalize-line-endings",
"predicates-core",
"regex",
"regex 1.9.4",
]
[[package]]
@ -709,7 +769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c"
dependencies = [
"env_logger",
"log",
"log 0.4.17",
]
[[package]]
@ -767,16 +827,29 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "regex"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
dependencies = [
"aho-corasick 0.6.10",
"memchr",
"regex-syntax 0.5.6",
"thread_local",
"utf8-ranges",
]
[[package]]
name = "regex"
version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29"
dependencies = [
"aho-corasick",
"aho-corasick 1.1.2",
"memchr",
"regex-automata 0.3.7",
"regex-syntax",
"regex-syntax 0.7.5",
]
[[package]]
@ -791,9 +864,18 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629"
dependencies = [
"aho-corasick",
"aho-corasick 1.1.2",
"memchr",
"regex-syntax",
"regex-syntax 0.7.5",
]
[[package]]
name = "regex-syntax"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
dependencies = [
"ucd-util",
]
[[package]]
@ -1000,6 +1082,15 @@ dependencies = [
"terminal_size",
]
[[package]]
name = "thread_local"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
dependencies = [
"lazy_static 1.4.0",
]
[[package]]
name = "tree-sitter"
version = "0.20.9"
@ -1007,7 +1098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4423c784fe11398ca91e505cdc71356b07b1a924fc8735cfab5333afe3e18bc"
dependencies = [
"cc",
"regex",
"regex 1.9.4",
]
[[package]]
@ -1017,7 +1108,7 @@ source = "git+https://github.com/Wilfred/tree_magic?branch=fix-panic-for-empty-s
dependencies = [
"bytecount",
"fnv",
"lazy_static",
"lazy_static 1.4.0",
"nom",
"once_cell",
"petgraph",
@ -1029,6 +1120,12 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "ucd-util"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abd2fc5d32b590614af8b0a20d837f32eca055edd0bbead59a9cfe80858be003"
[[package]]
name = "unicode-ident"
version = "1.0.0"
@ -1047,6 +1144,12 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "utf8-ranges"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba"
[[package]]
name = "version_check"
version = "0.9.4"

@ -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"

@ -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;
@ -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()