From 5d4b9ca5e23e52861c03fb840dda63acd9553d08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 03:09:20 +0000 Subject: [PATCH 1/2] build(deps): bump clap from 4.5.8 to 4.5.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.8 to 4.5.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.8...v4.5.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74e06dc8..3452d3d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,18 +164,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", From 9c11f11045c69c7f06d0ec82018b8968ec4f0391 Mon Sep 17 00:00:00 2001 From: hanbings Date: Tue, 9 Jul 2024 17:27:18 -0400 Subject: [PATCH 2/2] Implement `-noleaf` (#414) --- src/find/matchers/mod.rs | 5 +++++ src/find/mod.rs | 17 +++++++++++++++++ tests/find_cmd_tests.rs | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/find/matchers/mod.rs b/src/find/matchers/mod.rs index 97d238b0..fc3e480f 100644 --- a/src/find/matchers/mod.rs +++ b/src/find/matchers/mod.rs @@ -692,6 +692,11 @@ fn build_matcher_tree( return Ok((i, top_level_matcher.build())); } + "-noleaf" => { + // No change of behavior + config.no_leaf_dirs = true; + None + } "-d" | "-depth" => { // TODO add warning if it appears after actual testing criterion config.depth_first = true; diff --git a/src/find/mod.rs b/src/find/mod.rs index 80266798..17eb3603 100644 --- a/src/find/mod.rs +++ b/src/find/mod.rs @@ -21,6 +21,7 @@ pub struct Config { sorted_output: bool, help_requested: bool, version_requested: bool, + no_leaf_dirs: bool, } impl Default for Config { @@ -33,6 +34,10 @@ impl Default for Config { sorted_output: false, help_requested: false, version_requested: false, + // Directory information and traversal are done by walkdir, + // and this configuration field will exist as + // a compatibility item for GNU findutils. + no_leaf_dirs: false, } } } @@ -156,6 +161,7 @@ fn process_dir<'a>( } Ok(entry) => { let mut matcher_io = matchers::MatcherIO::new(deps); + if matcher.matches(&entry, &mut matcher_io) { found_count += 1; } @@ -1219,4 +1225,15 @@ mod tests { assert_eq!(rc, 0); } + + #[test] + #[cfg(unix)] + fn test_noleaf() { + use crate::find::tests::FakeDependencies; + + let deps = FakeDependencies::new(); + let rc = find_main(&["find", "./test_data/simple/subdir", "-noleaf"], &deps); + + assert_eq!(rc, 0); + } } diff --git a/tests/find_cmd_tests.rs b/tests/find_cmd_tests.rs index ae4c8b32..025123ee 100644 --- a/tests/find_cmd_tests.rs +++ b/tests/find_cmd_tests.rs @@ -881,3 +881,15 @@ fn find_samefile() { .stdout(predicate::str::is_empty()) .stderr(predicate::str::contains("not-exist-file")); } + +#[test] +#[serial(working_dir)] +fn find_noleaf() { + Command::cargo_bin("find") + .expect("found binary") + .args(["test_data/simple/subdir", "-noleaf"]) + .assert() + .success() + .stdout(predicate::str::contains("test_data/simple/subdir")) + .stderr(predicate::str::is_empty()); +}