Skip to content
Myr

`--ignore-contain`: ignore directories containing a named entry (e.g. [`CACHEDIR.TAG`](https://bford.info/cachedir/)).

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #1727.

authored by Ami Fischman · committed by Ami Fischman · parent e3a6f8b · Browse files · 6 files+41 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+41 added−1 removed

  • tests:+18 added−0 removed
  • other:+23 added−1 removed

6 files+41 added−1 removed

modified:src/cli.rs+10 added
526 unmodified lines
527 help = "Add hyperlinks to output paths"528 )]529 pub hyperlink: HyperlinkWhen,530531 /// Ignore directories containing the named entry.532 #[arg(533 long,534 value_name = "name",535 hide_short_help = true,536 help = "Ignore directories containing this name",537 long_help538 )]539 pub ignore_contain: Option<String>,540541 /// Set number of threads to use for searching & executing (default: number542 /// of available CPU cores)543 #[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = str::parse::<NonZeroUsize>)]544 pub threads: Option<NonZeroUsize>,
407 unmodified lines
modified:src/config.rs+3 added
128 unmodified lines
129 pub strip_cwd_prefix: bool,130131 /// Whether or not to use hyperlinks on paths132 pub hyperlink: bool,133134 /// A name that should stop traversal down its parent. (e.g. https://bford.info/cachedir/).135 pub ignore_contain: Option<String>,136}137138impl Config {139 /// Check whether results are being printed.
4 unmodified lines
modified:src/main.rs+1 added
324 unmodified lines
325 path_separator,326 actual_path_separator,327 max_results: opts.max_results(),328 strip_cwd_prefix: opts.strip_cwd_prefix(|| !(opts.null_separator || has_command)),329 ignore_contain: opts.ignore_contain,330 })331}332333fn extract_command(opts: &mut Opts, colored_output: bool) -> Result<Option<CommandSet>> {
159 unmodified lines
modified:src/walk.rs+8 added
558 unmodified lines
559 }560 }561 }562563 // Filter out directories containing a given name.564 if let Some(ref ignore_contain) = config.ignore_contain565 && entry_path.is_dir()566 && entry_path.join(ignore_contain).exists()567 {568 return WalkState::Skip;569 }570571 // Filter out unwanted sizes if it is a file and we have been given size constraints.572 if !config.size_constraints.is_empty() {573 if entry_path.is_file() {574 if let Some(metadata) = entry.metadata() {
103 unmodified lines
modified:tests/tests.rs+18 added
2705 unmodified lines
2706 );27072708 te.assert_output(&["--hyperlink=always", "a.foo"], &expected);2709}27102711#[test]2712fn test_ignore_contain() {2713 let te = TestEnv::new(2714 &["include", "exclude", "exclude/sub"],2715 &[2716 "top",2717 "include/foo",2718 "exclude/CACHEDIR.TAG",2719 "exclude/sub/nope",2720 ],2721 );2722 let expected = "include/2723 include/foo2724 symlink2725 top";2726 te.assert_output(&["--ignore-contain=CACHEDIR.TAG", "."], expected);2727}
modified:CHANGELOG.md+1 added-1 removed
1# Upcoming release23## Features4- Add `--ignore-contain` option to ignore directories containing a named entry (e.g. to ignore [`CACHEDIR.TAG`](https://bford.info/cachedir/)); see #1727 (@fischman).556## Bugfixes78- `--print0` combined with `--exec` will now print a `\0` between the output of each entry. Note that if there are multiple instances9 of `--exec`, the `\0` will be between each _set_ of commands, _not_ between each individual command run. Fixes #1797.
831 unmodified lines