From cbf3f11cf88884af8aff8c47f41c1ec12edf79c6 Mon Sep 17 00:00:00 2001 From: Jackson Theel Date: Mon, 21 Mar 2022 17:06:48 -0700 Subject: [PATCH] Make -u idempotent --- src/app.rs | 8 ++++---- src/main.rs | 2 +- tests/tests.rs | 14 +------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/app.rs b/src/app.rs index 01ddc1d..0b5578e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -102,12 +102,12 @@ pub fn build_app() -> Command<'static> { .short('u') .long("unrestricted") .overrides_with_all(&["ignore", "no-hidden"]) - .multiple_occurrences(true) + .multiple_occurrences(true) // Allowed for historical reasons .hide_short_help(true) - .help("Alias for '--no-ignore', and '--hidden' when given twice") + .help("Alias for '--no-ignore', and '--hidden'") .long_help( - "Alias for '--no-ignore'. Can be repeated. '-uu' is an alias for \ - '--no-ignore --hidden'.", + "Perform a search with no filters applied. Unfilters ignored \ + files and hidden files.", ), ) .arg( diff --git a/src/main.rs b/src/main.rs index 8bcd05e..6909ebf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -256,7 +256,7 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result= 2), + || matches.is_present("rg-alias-hidden-ignore")), read_fdignore: !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore")), read_vcsignore: !(matches.is_present("no-ignore") diff --git a/tests/tests.rs b/tests/tests.rs index 3436437..fb4ec59 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -656,18 +656,6 @@ fn test_no_ignore_aliases() { te.assert_output( &["-u", "foo"], - "./a.foo - ./fdignored.foo - ./gitignored.foo - ./one/b.foo - ./one/two/c.foo - ./one/two/C.Foo2 - ./one/two/three/d.foo - ./one/two/three/directory_foo", - ); - - te.assert_output( - &["-uu", "foo"], "./.hidden.foo ./a.foo ./fdignored.foo @@ -2039,7 +2027,7 @@ fn test_number_parsing_errors() { #[test_case("--no-ignore-vcs", &["--ignore-vcs"] ; "no-ignore-vcs")] #[test_case("--follow", &["--no-follow"] ; "follow")] #[test_case("--absolute-path", &["--relative-path"] ; "absolute-path")] -#[test_case("-u", &["--ignore"] ; "u")] +#[test_case("-u", &["--ignore", "--no-hidden"] ; "u")] #[test_case("-uu", &["--ignore", "--no-hidden"] ; "uu")] fn test_opposing(flag: &str, opposing_flags: &[&str]) { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);