Skip to content

Commit

Permalink
Add some debugging output explaining the choice of invocation for per…
Browse files Browse the repository at this point in the history
…-x-or-y config
  • Loading branch information
autarch committed Apr 24, 2024
1 parent f1311ce commit c8d0d99
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions precious-core/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit c8d0d99

Please sign in to comment.