mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
parent
b33ced2143
commit
1fb118d52f
3 changed files with 15 additions and 13 deletions
|
@ -298,13 +298,20 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult {
|
||||||
};
|
};
|
||||||
|
|
||||||
if single_threaded {
|
if single_threaded {
|
||||||
typos_cli::file::walk_path(walk.build(), selected_checks, &engine, reporter)
|
typos_cli::file::walk_path(
|
||||||
|
walk.build(),
|
||||||
|
selected_checks,
|
||||||
|
&engine,
|
||||||
|
reporter,
|
||||||
|
args.force_exclude,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
typos_cli::file::walk_path_parallel(
|
typos_cli::file::walk_path_parallel(
|
||||||
walk.build_parallel(),
|
walk.build_parallel(),
|
||||||
selected_checks,
|
selected_checks,
|
||||||
&engine,
|
&engine,
|
||||||
reporter,
|
reporter,
|
||||||
|
args.force_exclude,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
|
|
@ -669,9 +669,10 @@ pub fn walk_path(
|
||||||
checks: &dyn FileChecker,
|
checks: &dyn FileChecker,
|
||||||
engine: &crate::policy::ConfigEngine<'_>,
|
engine: &crate::policy::ConfigEngine<'_>,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
|
force_exclude: bool,
|
||||||
) -> Result<(), ignore::Error> {
|
) -> Result<(), ignore::Error> {
|
||||||
for entry in walk {
|
for entry in walk {
|
||||||
walk_entry(entry, checks, engine, reporter)?;
|
walk_entry(entry, checks, engine, reporter, force_exclude)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -681,11 +682,12 @@ pub fn walk_path_parallel(
|
||||||
checks: &dyn FileChecker,
|
checks: &dyn FileChecker,
|
||||||
engine: &crate::policy::ConfigEngine<'_>,
|
engine: &crate::policy::ConfigEngine<'_>,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
|
force_exclude: bool,
|
||||||
) -> Result<(), ignore::Error> {
|
) -> Result<(), ignore::Error> {
|
||||||
let error: std::sync::Mutex<Result<(), ignore::Error>> = std::sync::Mutex::new(Ok(()));
|
let error: std::sync::Mutex<Result<(), ignore::Error>> = std::sync::Mutex::new(Ok(()));
|
||||||
walk.run(|| {
|
walk.run(|| {
|
||||||
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
|
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
|
||||||
match walk_entry(entry, checks, engine, reporter) {
|
match walk_entry(entry, checks, engine, reporter, force_exclude) {
|
||||||
Ok(()) => ignore::WalkState::Continue,
|
Ok(()) => ignore::WalkState::Continue,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
*error.lock().unwrap() = Err(err);
|
*error.lock().unwrap() = Err(err);
|
||||||
|
@ -703,6 +705,7 @@ fn walk_entry(
|
||||||
checks: &dyn FileChecker,
|
checks: &dyn FileChecker,
|
||||||
engine: &crate::policy::ConfigEngine<'_>,
|
engine: &crate::policy::ConfigEngine<'_>,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
|
force_exclude: bool,
|
||||||
) -> Result<(), ignore::Error> {
|
) -> Result<(), ignore::Error> {
|
||||||
let entry = match entry {
|
let entry = match entry {
|
||||||
Ok(entry) => entry,
|
Ok(entry) => entry,
|
||||||
|
@ -722,7 +725,7 @@ fn walk_entry(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if entry.file_type().map(|t| t.is_file()).unwrap_or(true) {
|
if entry.file_type().map(|t| t.is_file()).unwrap_or(true) {
|
||||||
let explicit = entry.depth() == 0;
|
let explicit = entry.depth() == 0 && !force_exclude;
|
||||||
let (path, lookup_path) = if entry.is_stdin() {
|
let (path, lookup_path) = if entry.is_stdin() {
|
||||||
let path = std::path::Path::new("-");
|
let path = std::path::Path::new("-");
|
||||||
let cwd = std::env::current_dir().map_err(|err| {
|
let cwd = std::env::current_dir().map_err(|err| {
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "file.ignore ignore/file parent/ignore/file binary --force-exclude"
|
args = "file.ignore ignore/file parent/ignore/file binary --force-exclude"
|
||||||
stdin = ""
|
stdin = ""
|
||||||
stdout = """
|
stdout = ""
|
||||||
error: `hello` should be `goodbye`
|
|
||||||
--> binary:3:1
|
|
||||||
|
|
|
||||||
3 | hello
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
"""
|
|
||||||
stderr = ""
|
stderr = ""
|
||||||
status.code = 2
|
|
||||||
|
|
Loading…
Reference in a new issue