From d9b55f966cbffa8e201ffa525cadfc608938b3d0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Sep 2024 13:06:55 -0400 Subject: [PATCH] fix(cli): Allow negative expressions in extend-exclude Fixes #1099 --- crates/typos-cli/src/bin/typos-cli/main.rs | 6 +++--- .../typos-cli/tests/cmd/extend-exclude-inverted.toml | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/typos-cli/src/bin/typos-cli/main.rs b/crates/typos-cli/src/bin/typos-cli/main.rs index f0ba487..81e4d35 100644 --- a/crates/typos-cli/src/bin/typos-cli/main.rs +++ b/crates/typos-cli/src/bin/typos-cli/main.rs @@ -244,7 +244,7 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { let mut overrides = ignore::overrides::OverrideBuilder::new("."); for pattern in walk_policy.extend_exclude.iter() { overrides - .add(&format!("!{pattern}")) + .add(pattern) .with_code(proc_exit::sysexits::CONFIG_ERR)?; } let overrides = overrides @@ -268,8 +268,8 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { log::debug!("match({path:?}, {is_dir}) == {matched:?}"); match matched { ignore::Match::None => true, - ignore::Match::Ignore(_) => false, - ignore::Match::Whitelist(_) => true, + ignore::Match::Ignore(_) => true, + ignore::Match::Whitelist(_) => false, } }); } diff --git a/crates/typos-cli/tests/cmd/extend-exclude-inverted.toml b/crates/typos-cli/tests/cmd/extend-exclude-inverted.toml index 324f41d..b8e837b 100644 --- a/crates/typos-cli/tests/cmd/extend-exclude-inverted.toml +++ b/crates/typos-cli/tests/cmd/extend-exclude-inverted.toml @@ -1,4 +1,12 @@ bin.name = "typos" stdin = "" -stdout = "" +stdout = """ +error: `hte` should be `the` + --> ./checked/file.txt:1:1 + | +1 | hte + | ^^^ + | +""" stderr = "" +status.code = 2