1
0
Fork 0

"Writing lock file" message is only displayed if locker isn't fresh

pull/535/head
Tiago Ribeiro 2012-04-06 20:25:41 +01:00
parent 61beea3c8b
commit 13839bf52c
2 changed files with 15 additions and 5 deletions

View File

@ -305,8 +305,9 @@ class Installer
if (!$this->dryRun) { if (!$this->dryRun) {
if ($this->update || !$this->locker->isLocked()) { if ($this->update || !$this->locker->isLocked()) {
$this->locker->setLockData($localRepo->getPackages(), $aliases); if ($this->locker->setLockData($localRepo->getPackages(), $aliases)) {
$this->io->write('<info>Writing lock file</info>'); $this->io->write('<info>Writing lock file</info>');
}
} }
$localRepo->write(); $localRepo->write();

View File

@ -121,6 +121,8 @@ class Locker
* *
* @param array $packages array of packages * @param array $packages array of packages
* @param array $aliases array of aliases * @param array $aliases array of aliases
*
* @return Boolean
*/ */
public function setLockData(array $packages, array $aliases) public function setLockData(array $packages, array $aliases)
{ {
@ -129,6 +131,7 @@ class Locker
'packages' => array(), 'packages' => array(),
'aliases' => $aliases, 'aliases' => $aliases,
); );
foreach ($packages as $package) { foreach ($packages as $package) {
$name = $package->getPrettyName(); $name = $package->getPrettyName();
$version = $package->getPrettyVersion(); $version = $package->getPrettyVersion();
@ -144,19 +147,25 @@ class Locker
if ($package->isDev()) { if ($package->isDev()) {
$spec['source-reference'] = $package->getSourceReference(); $spec['source-reference'] = $package->getSourceReference();
} }
if ($package->getAlias() && $package->isInstalledAsAlias()) { if ($package->getAlias() && $package->isInstalledAsAlias()) {
$spec['alias'] = $package->getAlias(); $spec['alias'] = $package->getAlias();
} }
$lock['packages'][] = $spec; $lock['packages'][] = $spec;
} }
usort($lock['packages'], function ($a, $b) { usort($lock['packages'], function ($a, $b) {
return strcmp($a['package'], $b['package']); return strcmp($a['package'], $b['package']);
}); });
$this->lockFile->write($lock); if ($lock !== $this->getLockData()) {
$this->lockFile->write($lock);
$this->lockDataCache = null;
// invalidate cache return true;
$this->lockDataCache = null; }
return false;
} }
} }