1
0
Fork 0

Skip dependency packages required in composer.json in update whitelist

pull/740/head
Nils Adermann 2012-05-28 12:02:15 +02:00
parent dfe366152c
commit c7250917e8
2 changed files with 25 additions and 3 deletions

View File

@ -220,7 +220,11 @@ class Installer
$stabilityFlags = $this->locker->getStabilityFlags(); $stabilityFlags = $this->locker->getStabilityFlags();
} }
$this->whitelistUpdateDependencies($localRepo, $devMode); $this->whitelistUpdateDependencies(
$localRepo,
$devMode,
$this->package->getRequires(),
$this->package->getDevRequires());
// creating repository pool // creating repository pool
$pool = new Pool($minimumStability, $stabilityFlags); $pool = new Pool($minimumStability, $stabilityFlags);
@ -464,15 +468,30 @@ class Installer
/** /**
* Adds all dependencies of the update whitelist to the whitelist, too. * Adds all dependencies of the update whitelist to the whitelist, too.
* *
* Packages which are listed as requirements in the root package will be
* skipped including their dependencies, unless they are listed in the
* update whitelist themselves.
*
* @param RepositoryInterface $localRepo * @param RepositoryInterface $localRepo
* @param boolean $devMode * @param boolean $devMode
* @param array $rootRequires An array of links to packages in require of the root package
* @param array $rootDevRequires An array of links to packages in require-dev of the root package
*/ */
private function whitelistUpdateDependencies($localRepo, $devMode) private function whitelistUpdateDependencies($localRepo, $devMode, array $rootRequires, array $rootDevRequires)
{ {
if (!$this->updateWhitelist) { if (!$this->updateWhitelist) {
return; return;
} }
if ($devMode) {
$rootRequires = array_merge($rootRequires, $rootDevRequires);
}
$skipPackages = array();
foreach ($rootRequires as $require) {
$skipPackages[$require->getTarget()] = true;
}
$pool = new Pool; $pool = new Pool;
$pool->addRepository($localRepo); $pool->addRepository($localRepo);
@ -503,6 +522,9 @@ class Installer
$requirePackages = $pool->whatProvides($require->getTarget()); $requirePackages = $pool->whatProvides($require->getTarget());
foreach ($requirePackages as $requirePackage) { foreach ($requirePackages as $requirePackage) {
if (isset($skipPackages[$requirePackage->getName()])) {
continue;
}
$packageQueue->enqueue($requirePackage); $packageQueue->enqueue($requirePackage);
} }
} }

View File

@ -24,7 +24,7 @@ Update with a package whitelist only updates those packages and their dependenci
} }
--INSTALLED-- --INSTALLED--
[ [
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0", "fixed-dependency": "1.0.0" } }, { "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0", "fixed-dependency": "1.*" } },
{ "name": "dependency", "version": "1.0.0" }, { "name": "dependency", "version": "1.0.0" },
{ "name": "fixed-dependency", "version": "1.0.0", "require": { "fixed-sub-dependency": "1.*" } }, { "name": "fixed-dependency", "version": "1.0.0", "require": { "fixed-sub-dependency": "1.*" } },
{ "name": "fixed-sub-dependency", "version": "1.0.0" } { "name": "fixed-sub-dependency", "version": "1.0.0" }