Replace `dirs-next` crate with `etcetera` crate
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Utkarsh Gupta · committed by David Peter · parent a0370aa · Browse files · 3 files·+33 added−90 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+33 added−90 removed
- other:+33 added−90 removed
Provenance
- Commit
3ae0454- Tree
649ac13- Author
Utkarsh Gupta <utkarshgupta137@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
a0370aa
3 files changed+33 added−90 removed
modified:src/walk.rs+11 added-19 removed
8 unmodified lines9 use std::{borrow::Cow, io::Write};10 11 use anyhow::{anyhow, Result};12 use crossbeam_channel::{bounded, Receiver, RecvTimeoutError, Sender};13+use etcetera::BaseStrategy;14 use ignore::overrides::OverrideBuilder;15 use ignore::{self, WalkBuilder};16 use regex::bytes::Regex;17 71 unmodified lines89 walker.add_custom_ignore_filename(".fdignore");90 }91 92 if config.read_global_ignore {92- #[cfg(target_os = "macos")]93- let config_dir_op = std::env::var_os("XDG_CONFIG_HOME")94- .map(PathBuf::from)95- .filter(|p| p.is_absolute())96- .or_else(|| dirs_next::home_dir().map(|d| d.join(".config")));97-98- #[cfg(not(target_os = "macos"))]99- let config_dir_op = dirs_next::config_dir();100-101- if let Some(global_ignore_file) = config_dir_op102- .map(|p| p.join("fd").join("ignore"))103- .filter(|p| p.is_file())104- {105- let result = walker.add_ignore(global_ignore_file);106- match result {107- Some(ignore::Error::Partial(_)) => (),108- Some(err) => {109- print_error(format!("Malformed pattern in global ignore file. {}.", err));93+ if let Ok(basedirs) = etcetera::choose_base_strategy() {94+ let global_ignore_file = basedirs.config_dir().join("fd").join("ignore");95+ if global_ignore_file.is_file() {96+ let result = walker.add_ignore(global_ignore_file);97+ match result {98+ Some(ignore::Error::Partial(_)) => (),99+ Some(err) => {100+ print_error(format!("Malformed pattern in global ignore file. {}.", err));101+ }102+ None => (),103 }111- None => (),104 }105 }106 }107 438 unmodified linesmodified:Cargo.lock+21 added-70 removed
236 unmodified lines237 source = "registry+https://github.com/rust-lang/crates.io-index"238 checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"239 240 [[package]]241-name = "dirs-next"242-version = "2.0.0"243-source = "registry+https://github.com/rust-lang/crates.io-index"244-checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"245-dependencies = [246- "cfg-if",247- "dirs-sys-next",248-]249-250-[[package]]251-name = "dirs-sys-next"252-version = "0.1.2"253-source = "registry+https://github.com/rust-lang/crates.io-index"254-checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"255-dependencies = [256- "libc",257- "redox_users",258- "winapi",259-]260-261-[[package]]241 name = "errno"242 version = "0.2.8"243 source = "registry+https://github.com/rust-lang/crates.io-index"244 checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"24 unmodified lines269 "libc",270 ]271 272 [[package]]273+name = "etcetera"274+version = "0.8.0"275+source = "registry+https://github.com/rust-lang/crates.io-index"276+checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"277+dependencies = [278+ "cfg-if",279+ "home",280+ "windows-sys 0.48.0",281+]282+283+[[package]]284 name = "faccess"285 version = "0.2.4"286 source = "registry+https://github.com/rust-lang/crates.io-index"287 checksum = "59ae66425802d6a903e268ae1a08b8c38ba143520f227a205edf4e9c7e3e26d5"23 unmodified lines311 "clap_complete",312 "crossbeam-channel",313 "ctrlc",314 "diff",325- "dirs-next",315+ "etcetera",316 "faccess",317 "filetime",318 "globset",319 "humantime",31 unmodified lines351 source = "registry+https://github.com/rust-lang/crates.io-index"352 checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"353 354 [[package]]365-name = "getrandom"366-version = "0.2.8"367-source = "registry+https://github.com/rust-lang/crates.io-index"368-checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"369-dependencies = [370- "cfg-if",371- "libc",372- "wasi",373-]374-375-[[package]]355 name = "globset"356 version = "0.4.10"357 source = "registry+https://github.com/rust-lang/crates.io-index"358 checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"26 unmodified lines385 source = "registry+https://github.com/rust-lang/crates.io-index"386 checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"387 388 [[package]]389+name = "home"390+version = "0.5.4"391+source = "registry+https://github.com/rust-lang/crates.io-index"392+checksum = "747309b4b440c06d57b0b25f2aee03ee9b5e5397d288c60e21fc709bb98a7408"393+dependencies = [394+ "winapi",395+]396+397+[[package]]398 name = "humantime"399 version = "2.1.0"400 source = "registry+https://github.com/rust-lang/crates.io-index"401 checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"299 unmodified lines701 "bitflags 1.3.2",702 ]703 704 [[package]]717-name = "redox_users"718-version = "0.4.3"719-source = "registry+https://github.com/rust-lang/crates.io-index"720-checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"721-dependencies = [722- "getrandom",723- "redox_syscall 0.2.16",724- "thiserror",725-]726-727-[[package]]705 name = "regex"706 version = "1.7.3"707 source = "registry+https://github.com/rust-lang/crates.io-index"708 checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"159 unmodified lines868 "test-case-core",869 ]870 871 [[package]]895-name = "thiserror"896-version = "1.0.40"897-source = "registry+https://github.com/rust-lang/crates.io-index"898-checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"899-dependencies = [900- "thiserror-impl",901-]902-903-[[package]]904-name = "thiserror-impl"905-version = "1.0.40"906-source = "registry+https://github.com/rust-lang/crates.io-index"907-checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"908-dependencies = [909- "proc-macro2",910- "quote",911- "syn 2.0.2",912-]913-914-[[package]]872 name = "thread_local"873 version = "1.1.7"874 source = "registry+https://github.com/rust-lang/crates.io-index"875 checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"40 unmodified lines916 "winapi-util",917 ]918 919 [[package]]963-name = "wasi"964-version = "0.11.0+wasi-snapshot-preview1"965-source = "registry+https://github.com/rust-lang/crates.io-index"966-checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"967-968-[[package]]920 name = "wasm-bindgen"921 version = "0.2.84"922 source = "registry+https://github.com/rust-lang/crates.io-index"923 checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"211 unmodified linesmodified:Cargo.toml+1 added-1 removed
42 unmodified lines4344454647474849505144 unmodified lines42 unmodified linesctrlc = "3.2"humantime = "2.1"globset = "0.4"anyhow = "1.0"dirs-next = "2.0"etcetera = "0.8"normpath = "1.1.1"crossbeam-channel = "0.5.8"clap_complete = {version = "4.3.0", optional = true}faccess = "0.2.4"44 unmodified lines