Skip to content

Commit 8314a15

Browse files
committed
Add "--force-exclude" option
1 parent 442b119 commit 8314a15

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

.pre-commit-hooks.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
description: Source code spell checker, binary install
44
language: python
55
entry: typos
6-
args: [--write-changes]
6+
args: [--write-changes, --force-exclude]
77
types: [text]
88
stages: [commit, merge-commit, push, manual]
99

@@ -12,7 +12,7 @@
1212
description: Source code spell checker, Docker image
1313
language: docker
1414
entry: typos
15-
args: [--write-changes]
15+
args: [--write-changes, --force-exclude]
1616
types: [text]
1717
stages: [commit, merge-commit, push, manual]
1818

@@ -21,6 +21,6 @@
2121
description: Source code spell checker, source install
2222
language: rust
2323
entry: typos
24-
args: [--write-changes]
24+
args: [--write-changes, --force-exclude]
2525
types: [text]
2626
stages: [commit, merge-commit, push, manual]

crates/typos-cli/src/bin/typos-cli/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub(crate) struct Args {
4646
#[arg(short = 'j', long = "threads", default_value = "0")]
4747
pub(crate) threads: usize,
4848

49+
/// Respect excluded files even for paths passed explicitly.
50+
#[arg(long, help_heading = None)]
51+
pub(crate) force_exclude: bool,
52+
4953
/// Custom config file
5054
#[arg(short = 'c', long = "config", help_heading = "Config")]
5155
pub(crate) custom_config: Option<std::path::PathBuf>,

crates/typos-cli/src/bin/typos-cli/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult {
216216
let overrides = overrides
217217
.build()
218218
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
219+
if args.force_exclude {
220+
if let ignore::Match::Ignore(_) = overrides.matched(path, path.is_dir()) {
221+
continue;
222+
}
223+
}
219224
walk.overrides(overrides);
220225
}
221226

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
bin.name = "typos"
2-
args = "file.ignore"
2+
args = "file.ignore --force-exclude"
33
stdin = ""
4-
stdout = """
5-
error: `hello` should be `goodbye`
6-
--> file.ignore:1:1
7-
|
8-
1 | hello
9-
| ^^^^^
10-
|
11-
"""
4+
stdout = ""
125
stderr = ""
13-
status.code = 2
6+
status.code = 0

crates/typos-cli/tests/cmd/help.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Arguments:
1010
1111
Options:
1212
-j, --threads <THREADS> The approximate number of threads to use [default: 0]
13+
--force-exclude Respect excluded files even for paths passed explicitly
1314
-h, --help Print help
1415
-V, --version Print version
1516

docs/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Configuration is read from the following (in precedence order)
1818
|------------------------|-------------------|--------|-------------|
1919
| files.binary | --binary | bool | Check binary files as text |
2020
| files.extend-exclude | --exclude | list of strings | Typos-specific ignore globs (gitignore syntax) |
21+
| file.force-excude | --force-exclude | bool | Respect excluded files even for paths passed explicitly. |
2122
| files.ignore-hidden | --hidden | bool | Skip hidden files and directories. |
2223
| files.ignore-files | --ignore | bool | Respect ignore files. |
2324
| files.ignore-dot | --ignore-dot | bool | Respect .ignore files. |

0 commit comments

Comments
 (0)