Fix package filter on bump command, fixes #11053
parent
564f8bec24
commit
ec8bbe9056
|
@ -13,8 +13,10 @@
|
||||||
namespace Composer\Command;
|
namespace Composer\Command;
|
||||||
|
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
|
use Composer\Package\BasePackage;
|
||||||
use Composer\Package\Locker;
|
use Composer\Package\Locker;
|
||||||
use Composer\Package\Version\VersionBumper;
|
use Composer\Package\Version\VersionBumper;
|
||||||
|
use Composer\Pcre\Preg;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Composer\Console\Input\InputArgument;
|
use Composer\Console\Input\InputArgument;
|
||||||
|
@ -129,6 +131,18 @@ EOT
|
||||||
$tasks['require'] = $composer->getPackage()->getRequires();
|
$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 = [];
|
$updates = [];
|
||||||
foreach ($tasks as $key => $reqs) {
|
foreach ($tasks as $key => $reqs) {
|
||||||
foreach ($reqs as $pkgName => $link) {
|
foreach ($reqs as $pkgName => $link) {
|
||||||
|
|
|
@ -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' => [
|
yield 'bump works from installed repo without lock file' => [
|
||||||
[
|
[
|
||||||
'require' => [
|
'require' => [
|
||||||
|
|
Loading…
Reference in New Issue