From c95b4d05fdf45c8d48268fa64dc59f63e9ada27b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 19 Feb 2012 16:34:35 +0100 Subject: [PATCH] Fix forcing of the source-ref from lock file --- src/Composer/Command/InstallCommand.php | 4 +++- src/Composer/Package/Locker.php | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 760c14e8f..5fe2e64db 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -236,9 +236,11 @@ EOT $package = $operation->getPackage(); } if ($package && $package->isDev()) { - foreach ($composer->getLocker()->getLockedPackages() as $lockedPackage) { + $lockData = $composer->getLocker()->getLockData(); + foreach ($lockData['packages'] as $lockedPackage) { if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) { $package->setSourceReference($lockedPackage['source-reference']); + break; } } } diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 255835ec3..24aafae8f 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -69,11 +69,7 @@ class Locker */ public function getLockedPackages() { - if (!$this->isLocked()) { - throw new \LogicException('No lockfile found. Unable to read locked packages'); - } - - $lockList = $this->lockFile->read(); + $lockList = $this->getLockData(); $packages = array(); foreach ($lockList['packages'] as $info) { $package = $this->repositoryManager->getLocalRepository()->findPackage($info['package'], $info['version']); @@ -95,6 +91,15 @@ class Locker return $packages; } + public function getLockData() + { + if (!$this->isLocked()) { + throw new \LogicException('No lockfile found. Unable to read locked packages'); + } + + return $this->lockFile->read(); + } + /** * Locks provided packages into lockfile. *