Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch "validate --no-check-lock" #10723

Merged
merged 1 commit into from Apr 13, 2022
Merged

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 a8d3689 to 59a541d Compare Apr 12, 2022
@ktomk ktomk changed the base branch from main to 2.2 Apr 12, 2022
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch 3 times, most recently from 49eb14b to dc84f03 Compare Apr 12, 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.

issue: composer#10715
@ktomk ktomk force-pushed the patch-validate-no-check-lock branch from 132d3a4 to 939c998 Compare Apr 12, 2022
@ktomk ktomk marked this pull request as ready for review Apr 12, 2022
@@ -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)'),
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
21 checks passed
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.

None yet

3 participants