Parcourir la source

Fix forcing of the source-ref from lock file

Jordi Boggiano il y a 13 ans
Parent
commit
c95b4d05fd
2 fichiers modifiés avec 13 ajouts et 6 suppressions
  1. 3 1
      src/Composer/Command/InstallCommand.php
  2. 10 5
      src/Composer/Package/Locker.php

+ 3 - 1
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;
                             }
                         }
                     }

+ 10 - 5
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.
      *