Skip to content

Conversation

@ktomk
Copy link
Contributor

@ktomk ktomk commented Apr 11, 2022

if no lock-file is configured, turn lock file validation errors into warnings (implicit --no-check-lock) unless those are explicitly promoted via the new --check-lock option.

  • {"config": {"lock": false}} is an implicit --no-check-lock for composer validate.
  • --check-lock overrides an (implicit or explicit) --no-check-lock, always.

rationale is that if no composer.lock file is configured in composer.json, the validate command should not fatal over it but instead demote to warning as the suggestion given in the warning won't work unless composer.lock is configured again (and there is no error as the lock-file is ignored by composer).

the difference this makes is the one between an exit status of zero or non-zero, between success and failure.

that is, if (and as) composer validate is used in check scripts (e.g. CI, tests, hooks etc.), it won't stumble over old lock-file artifacts, whatever the reasons may be.

(originally reported and fix idea / context in #10715)

@ktomk ktomk force-pushed the patch-validate-no-check-lock branch from 7e4a8b7 to 50c999b Compare April 11, 2022 22:33
@ktomk ktomk closed this Apr 11, 2022
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch from 50c999b to 9bfd059 Compare April 11, 2022 22:39
@ktomk ktomk reopened this Apr 11, 2022
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch 3 times, most recently from 983d680 to a8d3689 Compare April 12, 2022 00:09
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch from a8d3689 to 59a541d Compare April 12, 2022 15:02
@ktomk ktomk changed the base branch from main to 2.2 April 12, 2022 16:42
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch 3 times, most recently from 49eb14b to dc84f03 Compare April 12, 2022 20:10
if no lock-file is configured, turn lock file validation errors into
warnings (implicit --no-check-lock) unless those are explicitly promoted
via the new --check-lock option.

- `{"config": {"lock": false}}` is an implicit `--no-check-lock` for
  composer validate.
- `--check-lock` overrides an (implicit or explicit) `--no-check-lock`,
  always.

issue: composer#10715
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch from 132d3a4 to 939c998 Compare April 12, 2022 20:37
@ktomk ktomk marked this pull request as ready for review April 12, 2022 20:39
->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)'),
Copy link
Member

@Seldaek Seldaek Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this simpler, or leave the flag out altogether as I don't really see the point if you disabled the lock file..

Suggested change
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('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even when config.lock is false)'),

@Seldaek Seldaek added this to the 2.2 milestone Apr 13, 2022
@Seldaek Seldaek merged commit d64e32c into composer:2.2 Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants