Parcourir la source

Do not reset references on update mirrors if VCS type has changed

Nils Adermann il y a 5 ans
Parent
commit
cc274ebdf4
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      src/Composer/DependencyResolver/LockTransaction.php

+ 6 - 1
src/Composer/DependencyResolver/LockTransaction.php

@@ -158,9 +158,14 @@ class LockTransaction
         foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
             if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
                 // if we're just updating mirrors we need to reset references to the same as currently "present" packages' references to keep the lock file as-is
+                // we do not reset references if the currently present package didn't have any, or if the type of VCS has changed
                 if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
                     foreach ($this->presentMap as $presentPackage) {
-                        if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion() && $presentPackage->getSourceReference()) {
+                        if ($package->getName() == $presentPackage->getName() &&
+                            $package->getVersion() == $presentPackage->getVersion() &&
+                            $presentPackage->getSourceReference() &&
+                            $presentPackage->getSourceType() === $package->getSourceType()
+                        ) {
                             $package->setSourceDistReferences($presentPackage->getSourceReference());
                         }
                     }