Skip to content

Commit

Permalink
implicit "--no-check-lock" (10715, --no-check-lock; 2/?)
Browse files Browse the repository at this point in the history
... --check-lock overrides (implicit) --no-check-lock ...

(next is to check for InputOption::VALUE_NEGATABLE [1])

issue: 10715
[1]: https://symfony.com/blog/new-in-symfony-5-3-negatable-command-options
  • Loading branch information
ktomk committed Apr 11, 2022
1 parent cf4b32d commit 50c999b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Composer/Command/ValidateCommand.php
Expand Up @@ -45,6 +45,7 @@ protected function configure()
->setDescription('Validates a composer.json and composer.lock.')
->setDefinition(array(
new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even config.lock is false, overrides --no-check-lock)'),
new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
Expand Down Expand Up @@ -96,6 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$lockErrors = array();
$composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
$checkLock = $checkLock && $composer->getConfig()->getBool('lock'); // config.lock = false ~= implicit --no-check-lock
$checkLock = $checkLock || (bool)$input->getOption('check-lock'); // --check-lock overrides
$locker = $composer->getLocker();
if ($locker->isLocked() && !$locker->isFresh()) {
$lockErrors[] = '- The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.';
Expand Down

0 comments on commit 50c999b

Please sign in to comment.