1
0
Fork 0

Add support for stabilities in lock file

pull/592/head
Jordi Boggiano 2012-05-11 17:20:10 +02:00
parent a3018c43eb
commit 0936670213
3 changed files with 40 additions and 13 deletions

View File

@ -180,7 +180,9 @@ class Installer
$updatedLock = $this->locker->setLockData(
$this->repositoryManager->getLocalRepository()->getPackages(),
$this->devMode ? $this->repositoryManager->getLocalDevRepository()->getPackages() : null,
$aliases
$aliases,
$this->package->getMinimumStability(),
$this->package->getStabilityFlags()
);
if ($updatedLock) {
$this->io->write('<info>Writing lock file</info>');
@ -202,13 +204,18 @@ class Installer
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
$minimumStability = $this->package->getMinimumStability();
$stabilityFlags = $this->package->getStabilityFlags();
// initialize locker to create aliased packages
if (!$this->update && $this->locker->isLocked($devMode)) {
$lockedPackages = $this->locker->getLockedPackages($devMode);
$minimumStability = $this->locker->getMinimumStability();
$stabilityFlags = $this->locker->getStabilityFlags();
}
// creating repository pool
$pool = new Pool($this->package->getMinimumStability(), $this->package->getStabilityFlags());
$pool = new Pool($minimumStability, $stabilityFlags);
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);

View File

@ -82,10 +82,10 @@ class Locker
*/
public function getLockedPackages($dev = false)
{
$lockList = $this->getLockData();
$lockData = $this->getLockData();
$packages = array();
$lockedPackages = $dev ? $lockList['packages-dev'] : $lockList['packages'];
$lockedPackages = $dev ? $lockData['packages-dev'] : $lockData['packages'];
$repo = $dev ? $this->repositoryManager->getLocalDevRepository() : $this->repositoryManager->getLocalRepository();
foreach ($lockedPackages as $info) {
@ -128,22 +128,38 @@ class Locker
return $packages;
}
public function getMinimumStability()
{
$lockData = $this->getLockData();
// TODO BC change dev to stable end of june?
return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'dev';
}
public function getStabilityFlags()
{
$lockData = $this->getLockData();
return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
}
public function getAliases()
{
$lockList = $this->getLockData();
return isset($lockList['aliases']) ? $lockList['aliases'] : array();
$lockData = $this->getLockData();
return isset($lockData['aliases']) ? $lockData['aliases'] : array();
}
public function getLockData()
{
if (!$this->lockFile->exists()) {
throw new \LogicException('No lockfile found. Unable to read locked packages');
}
if (null !== $this->lockDataCache) {
return $this->lockDataCache;
}
if (!$this->lockFile->exists()) {
throw new \LogicException('No lockfile found. Unable to read locked packages');
}
return $this->lockDataCache = $this->lockFile->read();
}
@ -156,13 +172,15 @@ class Locker
*
* @return Boolean
*/
public function setLockData(array $packages, $devPackages, array $aliases)
public function setLockData(array $packages, $devPackages, array $aliases, $minimumStability, array $stabilityFlags)
{
$lock = array(
'hash' => $this->hash,
'packages' => null,
'packages-dev' => null,
'aliases' => $aliases,
'minimum-stability' => $minimumStability,
'stability-flags' => $stabilityFlags,
);
$lock['packages'] = $this->lockPackages($packages);

View File

@ -157,9 +157,11 @@ class LockerTest extends \PHPUnit_Framework_TestCase
),
'packages-dev' => array(),
'aliases' => array(),
'minimum-stability' => 'dev',
'stability-flags' => array(),
));
$locker->setLockData(array($package1, $package2), array(), array());
$locker->setLockData(array($package1, $package2), array(), array(), 'dev', array());
}
public function testLockBadPackages()
@ -177,7 +179,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('LogicException');
$locker->setLockData(array($package1), array(), array());
$locker->setLockData(array($package1), array(), array(), 'dev', array());
}
public function testIsFresh()