From e857a8216cc72600fe4ae4d067467272d149f428 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 26 Nov 2020 11:28:17 +0100 Subject: [PATCH] Make sure mirror update fails if no lock file is present --- src/Composer/Installer.php | 8 +++----- .../Fixtures/installer/partial-update-without-lock.test | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 4a2289bd1..8058cb0b3 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -367,12 +367,10 @@ class Installer // doing a full update } - if ($this->updateAllowList) { - if (!$lockedRepository) { - $this->io->writeError('Cannot update only a partial set of packages without a lock file present.', true, IOInterface::QUIET); + if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) { + $this->io->writeError('Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.', true, IOInterface::QUIET); - return 1; - } + return 1; } $this->io->writeError('Loading composer repositories with package information'); diff --git a/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test b/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test index 74007af7b..1738b2a84 100644 --- a/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test +++ b/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test @@ -31,7 +31,7 @@ Partial update without lock file should error --RUN-- update b/unstable --EXPECT-OUTPUT-- -Cannot update only a partial set of packages without a lock file present. +Cannot update only a partial set of packages without a lock file present. Run `composer update` to generate a lock file. --EXPECT-EXIT-CODE-- 1 --EXPECT--