From c8d0d990542238773956406a13e8c8705284d6f8 Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Wed, 24 Apr 2024 16:28:33 +0800 Subject: [PATCH] Add some debugging output explaining the choice of invocation for per-x-or-y config --- precious-core/src/command.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/precious-core/src/command.rs b/precious-core/src/command.rs index 76fd3b1..fd4bab1 100644 --- a/precious-core/src/command.rs +++ b/precious-core/src/command.rs @@ -327,22 +327,40 @@ impl LintOrTidyCommand { ActualInvoke::PerFile, ), Invoke::PerFileOrDir(n) => { - if files.clone().count() < n { + let count = files.clone().count(); + if count < n { + debug!( + "Invoking {} once per file for {count} files, which is less than {n}.", + self.name, + ); ( files.sorted().map(|f| vec![f.as_path()]).collect(), ActualInvoke::PerFile, ) } else { + debug!( + "Invoking {} once per directory for {count} files, which is at least {n}.", + self.name, + ); (Self::files_to_dirs(files)?, ActualInvoke::PerDir) } } Invoke::PerFileOrOnce(n) => { - if files.clone().count() < n { + let count = files.clone().count(); + if count < n { + debug!( + "Invoking {} once per file for {count} files, which is less than {n}.", + self.name, + ); ( files.sorted().map(|f| vec![f.as_path()]).collect(), ActualInvoke::PerFile, ) } else { + debug!( + "Invoking {} once for all {count} files, which is at least {n}.", + self.name, + ); ( vec![files.sorted().map(PathBuf::as_path).collect()], ActualInvoke::Once, @@ -353,9 +371,15 @@ impl LintOrTidyCommand { Invoke::PerDir => (Self::files_to_dirs(files)?, ActualInvoke::PerDir), Invoke::PerDirOrOnce(n) => { let dirs = Self::files_to_dirs(files.clone())?; - if dirs.len() < n { + let count = dirs.len(); + if count < n { + debug!("Invoking {} once per directory because there are fewer than {n} directories.", self.name); (dirs, ActualInvoke::PerDir) } else { + debug!( + "Invoking {} once for all {count} directories, which is at least {n}.", + self.name, + ); ( vec![files.sorted().map(PathBuf::as_path).collect()], ActualInvoke::Once,