Skip to content

Commit

Permalink
Allow --no-diffs to be configured via configuration file (#3598)
Browse files Browse the repository at this point in the history
  • Loading branch information
yguedidi committed Apr 10, 2023
1 parent ebc2e7e commit 27364c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public function parallel(int $seconds = 120, int $maxNumberOfProcess = 16, int $
$parameters->set(Option::PARALLEL_JOB_SIZE, $jobSize);
}

public function noDiffs(): void
{
$parameters = $this->parameters();
$parameters->set(Option::NO_DIFFS, true);
}

/**
* @param array<int|string, mixed> $criteria
*/
Expand Down
13 changes: 12 additions & 1 deletion src/Configuration/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function createFromInput(InputInterface $input): Configuration
$outputFormat = (string) $input->getOption(Option::OUTPUT_FORMAT);
$showProgressBar = $this->shouldShowProgressBar($input, $outputFormat);

$showDiffs = ! (bool) $input->getOption(Option::NO_DIFFS);
$showDiffs = $this->shouldShowDiffs($input);

$paths = $this->resolvePaths($input);

Expand Down Expand Up @@ -82,6 +82,17 @@ private function shouldShowProgressBar(InputInterface $input, string $outputForm
return $outputFormat === ConsoleOutputFormatter::NAME;
}

private function shouldShowDiffs(InputInterface $input): bool
{
$noDiffs = (bool) $input->getOption(Option::NO_DIFFS);
if ($noDiffs) {
return false;
}

// fallback to parameter
return ! $this->parameterProvider->provideBoolParameter(Option::NO_DIFFS);
}

/**
* @param string[] $commandLinePaths
* @return string[]
Expand Down

0 comments on commit 27364c5

Please sign in to comment.