1
0
Fork 0

Merge remote-tracking branch 'athieriot/update-regex'

pull/1410/merge
Jordi Boggiano 2012-12-13 15:34:54 +01:00
commit 702742e15f
3 changed files with 61 additions and 1 deletions

View File

@ -96,6 +96,10 @@ If you just want to update a few packages and not all, you can list them as such
$ php composer.phar update vendor/package vendor/package2
You can also use wildcards to update a bunch of packages at once:
$ php composer.phar update vendor/*
### Options
* **--prefer-source:** Install packages from `source` when available.

View File

@ -624,7 +624,15 @@ class Installer
throw new \LogicException('isUpdateable should only be called when a whitelist is present');
}
return isset($this->updateWhitelist[$package->getName()]);
foreach($this->updateWhitelist as $whiteListedPattern => $void) {
$cleanedWhiteListedPattern = str_replace('\*', '.*', preg_quote($whiteListedPattern));
if(preg_match("#^".$cleanedWhiteListedPattern."$#i", $package->getName())) {
return true;
}
}
return false;
}
/**

View File

@ -0,0 +1,48 @@
--TEST--
Update with a package whitelist only updates those corresponding to the pattern
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "vendor/Test-Package", "version": "2.0" },
{ "name": "vendor/NotMe", "version": "2.0" },
{ "name": "exact/Test-Package", "version": "2.0" },
{ "name": "notexact/TestPackage", "version": "2.0" },
{ "name": "all/Package1", "version": "2.0" },
{ "name": "all/Package2", "version": "2.0" },
{ "name": "another/another", "version": "2.0" },
{ "name": "no/regexp", "version": "2.0" }
]
}
],
"require": {
"vendor/Test-Package": "*.*",
"vendor/NotMe": "*.*",
"exact/Test-Package": "*.*",
"notexact/TestPackage": "*.*",
"all/Package1": "*.*",
"all/Package2": "*.*",
"another/another": "*.*",
"no/regexp": "*.*"
}
}
--INSTALLED--
[
{ "name": "vendor/Test-Package", "version": "1.0" },
{ "name": "vendor/NotMe", "version": "1.0" },
{ "name": "exact/Test-Package", "version": "1.0" },
{ "name": "notexact/TestPackage", "version": "1.0" },
{ "name": "all/Package1", "version": "1.0" },
{ "name": "all/Package2", "version": "1.0" },
{ "name": "another/another", "version": "1.0" },
{ "name": "no/regexp", "version": "1.0" }
]
--RUN--
update vendor/Test* exact/Test-Package notexact/Test all/* no/reg?xp
--EXPECT--
Updating vendor/Test-Package (1.0) to vendor/Test-Package (2.0)
Updating exact/Test-Package (1.0) to exact/Test-Package (2.0)
Updating all/Package1 (1.0) to all/Package1 (2.0)
Updating all/Package2 (1.0) to all/Package2 (2.0)