mirror of
https://github.com/crate-ci/typos.git
synced 2025-02-13 08:40:29 -05:00
Merge pull request #869 from epage/exclude
fix(cli): Respect force-exclude for simple exclude patterns
This commit is contained in:
commit
f01cfa581c
5 changed files with 13 additions and 6 deletions
|
@ -188,7 +188,7 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: file_list and args.path are mutually exclusive, enforced by clap
|
// Note: file_list and args.path are mutually exclusive, enforced by clap
|
||||||
for path in file_list.as_ref().unwrap_or(&args.path) {
|
'path: for path in file_list.as_ref().unwrap_or(&args.path) {
|
||||||
// Note paths are passed through stdin, `-` is treated like a normal path
|
// Note paths are passed through stdin, `-` is treated like a normal path
|
||||||
let cwd = if path == std::path::Path::new("-") {
|
let cwd = if path == std::path::Path::new("-") {
|
||||||
if args.file_list.is_some() {
|
if args.file_list.is_some() {
|
||||||
|
@ -244,8 +244,14 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult {
|
||||||
.build()
|
.build()
|
||||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||||
if args.force_exclude {
|
if args.force_exclude {
|
||||||
if let ignore::Match::Ignore(_) = overrides.matched(path, path.is_dir()) {
|
let mut ancestors = path.ancestors().collect::<Vec<_>>();
|
||||||
continue;
|
ancestors.reverse();
|
||||||
|
for path in ancestors {
|
||||||
|
match overrides.matched(path, path.is_dir()) {
|
||||||
|
ignore::Match::None => {}
|
||||||
|
ignore::Match::Ignore(_) => continue 'path,
|
||||||
|
ignore::Match::Whitelist(_) => break,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walk.overrides(overrides);
|
walk.overrides(overrides);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[files]
|
[files]
|
||||||
extend-exclude = ["file.ignore"]
|
extend-exclude = ["file.ignore", "ignore"]
|
||||||
|
|
||||||
[default.extend-identifiers]
|
[default.extend-identifiers]
|
||||||
hello = "goodbye"
|
hello = "goodbye"
|
||||||
|
|
1
crates/typos-cli/tests/cmd/force-exclude.in/ignore/file
Normal file
1
crates/typos-cli/tests/cmd/force-exclude.in/ignore/file
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hello
|
|
@ -0,0 +1 @@
|
||||||
|
hello
|
|
@ -1,6 +1,5 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "file.ignore --force-exclude"
|
args = "file.ignore ignore/file parent/ignore/file --force-exclude"
|
||||||
stdin = ""
|
stdin = ""
|
||||||
stdout = ""
|
stdout = ""
|
||||||
stderr = ""
|
stderr = ""
|
||||||
status.code = 0
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue