From 13839bf52c0f63d5fc705f6a681f19903a43280f Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 6 Apr 2012 20:25:41 +0100 Subject: [PATCH] "Writing lock file" message is only displayed if locker isn't fresh --- src/Composer/Installer.php | 5 +++-- src/Composer/Package/Locker.php | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 25483799d..1f016ab00 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -305,8 +305,9 @@ class Installer if (!$this->dryRun) { if ($this->update || !$this->locker->isLocked()) { - $this->locker->setLockData($localRepo->getPackages(), $aliases); - $this->io->write('Writing lock file'); + if ($this->locker->setLockData($localRepo->getPackages(), $aliases)) { + $this->io->write('Writing lock file'); + } } $localRepo->write(); diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index e33e25b68..25fb6c25f 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -121,6 +121,8 @@ class Locker * * @param array $packages array of packages * @param array $aliases array of aliases + * + * @return Boolean */ public function setLockData(array $packages, array $aliases) { @@ -129,6 +131,7 @@ class Locker 'packages' => array(), 'aliases' => $aliases, ); + foreach ($packages as $package) { $name = $package->getPrettyName(); $version = $package->getPrettyVersion(); @@ -144,19 +147,25 @@ class Locker if ($package->isDev()) { $spec['source-reference'] = $package->getSourceReference(); } + if ($package->getAlias() && $package->isInstalledAsAlias()) { $spec['alias'] = $package->getAlias(); } $lock['packages'][] = $spec; } + usort($lock['packages'], function ($a, $b) { return strcmp($a['package'], $b['package']); }); - $this->lockFile->write($lock); + if ($lock !== $this->getLockData()) { + $this->lockFile->write($lock); + $this->lockDataCache = null; - // invalidate cache - $this->lockDataCache = null; + return true; + } + + return false; } }