Преглед изворни кода

Fix more issues with dev-master normalization in aliases

Jordi Boggiano пре 5 година
родитељ
комит
7cca451312
2 измењених фајлова са 14 додато и 4 уклоњено
  1. 10 2
      src/Composer/Package/AliasPackage.php
  2. 4 2
      src/Composer/Package/Loader/ArrayLoader.php

+ 10 - 2
src/Composer/Package/AliasPackage.php

@@ -173,19 +173,27 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
      */
     protected function replaceSelfVersionDependencies(array $links, $linkType)
     {
+        // for self.version requirements, we use the original package's branch name instead of 9999999-dev, to avoid leaking 9999999-dev to users
+        $prettyVersion = $this->prettyVersion;
+        if ($prettyVersion === '9999999-dev') {
+            $prettyVersion = $this->aliasOf->getPrettyVersion();
+        }
+
         if (in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
             $newLinks = array();
             foreach ($links as $link) {
                 // link is self.version, but must be replacing also the replaced version
                 if ('self.version' === $link->getPrettyConstraint()) {
-                    $newLinks[] = new Link($link->getSource(), $link->getTarget(), new Constraint('=', $this->version), $linkType, $this->prettyVersion);
+                    $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
+                    $constraint->setPrettyString($prettyVersion);
                 }
             }
             $links = array_merge($links, $newLinks);
         } else {
             foreach ($links as $index => $link) {
                 if ('self.version' === $link->getPrettyConstraint()) {
-                    $links[$index] = new Link($link->getSource(), $link->getTarget(), new Constraint('=', $this->version), $linkType, $this->prettyVersion);
+                    $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
+                    $constraint->setPrettyString($prettyVersion);
                 }
             }
         }

+ 4 - 2
src/Composer/Package/Loader/ArrayLoader.php

@@ -247,11 +247,13 @@ class ArrayLoader implements LoaderInterface
         }
 
         if ($aliasNormalized = $this->getBranchAlias($config)) {
+            $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
+
             if ($package instanceof RootPackageInterface) {
-                return new RootAliasPackage($package, $aliasNormalized, preg_replace('{(\.9{7})+}', '.x', $aliasNormalized));
+                return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
             }
 
-            return new AliasPackage($package, $aliasNormalized, preg_replace('{(\.9{7})+}', '.x', $aliasNormalized));
+            return new AliasPackage($package, $aliasNormalized, $prettyAlias);
         }
 
         return $package;