From 564f8bec2494e4f5a9ae1fbea0de6bdd89d7de77 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 14 Sep 2022 13:23:17 +0200 Subject: [PATCH 1/3] Fix type error, fixes #11052 --- src/Composer/Downloader/ArchiveDownloader.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index db8c04391..a6648bcdf 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -93,7 +93,10 @@ abstract class ArchiveDownloader extends FileDownloader $filesystem->removeDirectory($path); } $this->removeCleanupPath($package, $temporaryDir); - $this->removeCleanupPath($package, realpath($path)); + $realpath = realpath($path); + if ($realpath !== false) { + $this->removeCleanupPath($package, $realpath); + } }; try { From ec8bbe905670295af84f7f04810cde667bac0afa Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 14 Sep 2022 14:00:27 +0200 Subject: [PATCH 2/3] Fix package filter on bump command, fixes #11053 --- src/Composer/Command/BumpCommand.php | 14 ++++++++++++ .../Composer/Test/Command/BumpCommandTest.php | 22 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Composer/Command/BumpCommand.php b/src/Composer/Command/BumpCommand.php index d7ae33488..b36908983 100644 --- a/src/Composer/Command/BumpCommand.php +++ b/src/Composer/Command/BumpCommand.php @@ -13,8 +13,10 @@ namespace Composer\Command; use Composer\Package\AliasPackage; +use Composer\Package\BasePackage; use Composer\Package\Locker; use Composer\Package\Version\VersionBumper; +use Composer\Pcre\Preg; use Composer\Util\Filesystem; use Symfony\Component\Console\Input\InputInterface; use Composer\Console\Input\InputArgument; @@ -129,6 +131,18 @@ EOT $tasks['require'] = $composer->getPackage()->getRequires(); } + $packagesFilter = $input->getArgument('packages'); + if (count($packagesFilter) > 0) { + $pattern = BasePackage::packageNamesToRegexp(array_unique(array_map('strtolower', $packagesFilter))); + foreach ($tasks as $key => $reqs) { + foreach ($reqs as $pkgName => $link) { + if (!Preg::isMatch($pattern, $pkgName)) { + unset($tasks[$key][$pkgName]); + } + } + } + } + $updates = []; foreach ($tasks as $key => $reqs) { foreach ($reqs as $pkgName => $link) { diff --git a/tests/Composer/Test/Command/BumpCommandTest.php b/tests/Composer/Test/Command/BumpCommandTest.php index 63e7cf30f..cf0dc3723 100644 --- a/tests/Composer/Test/Command/BumpCommandTest.php +++ b/tests/Composer/Test/Command/BumpCommandTest.php @@ -115,6 +115,28 @@ class BumpCommandTest extends TestCase ], ]; + yield 'bump only listed with packages arg' => [ + [ + 'require' => [ + 'first/pkg' => '^2.0', + 'second/pkg' => '3.*', + ], + 'require-dev' => [ + 'dev/pkg' => '~2.0', + ], + ], + ['packages' => ['first/pkg', 'dev/*']], + [ + 'require' => [ + 'first/pkg' => '^2.3.4', + 'second/pkg' => '3.*', + ], + 'require-dev' => [ + 'dev/pkg' => '^2.3.4.5', + ], + ], + ]; + yield 'bump works from installed repo without lock file' => [ [ 'require' => [ From fc75efd711f7520b0271914f62da268ba936ac31 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 5 Sep 2022 16:54:24 +0200 Subject: [PATCH 3/3] =?UTF-8?q?`require`=20command:=20allow=20`=E2=80=94fi?= =?UTF-8?q?xed`=20option=20for=20library=20dev=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Composer/Command/RequireCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 5b4e1e3de..6ce7a0c69 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -173,8 +173,8 @@ EOT /** * @see https://github.com/composer/composer/pull/8313#issuecomment-532637955 */ - if ($packageType !== 'project') { - $io->writeError('The "--fixed" option is only allowed for packages with a "project" type to prevent possible misuses.'); + if ($packageType !== 'project' && !$input->getOption('dev')) { + $io->writeError('The "--fixed" option is only allowed for packages with a "project" type or for dev dependencies to prevent possible misuses.'); if (!isset($config['type'])) { $io->writeError('If your package is not a library, you can explicitly specify the "type" by using "composer config type project".');