Skip to content

Commit

Permalink
fix(cli): Allow negative expressions in extend-exclude
Browse files Browse the repository at this point in the history
Fixes #1099
  • Loading branch information
epage committed Sep 16, 2024
1 parent 777cf42 commit d9b55f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions crates/typos-cli/src/bin/typos-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
});
}
Expand Down
10 changes: 9 additions & 1 deletion crates/typos-cli/tests/cmd/extend-exclude-inverted.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9b55f9

Please sign in to comment.