Browse Source

Load root packages as aliases if they are aliased so that they replace everything

Jordi Boggiano 13 years ago
parent
commit
a4c2337433
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/Composer/Package/Loader/RootPackageLoader.php

+ 11 - 7
src/Composer/Package/Loader/RootPackageLoader.php

@@ -15,6 +15,7 @@ namespace Composer\Package\Loader;
 use Composer\Package\Version\VersionParser;
 use Composer\Repository\RepositoryManager;
 use Composer\Util\ProcessExecutor;
+use Composer\Package\AliasPackage;
 
 /**
  * ArrayLoader built for the sole purpose of loading the root package
@@ -48,13 +49,6 @@ class RootPackageLoader extends ArrayLoader
                 foreach ($this->process->splitLines($output) as $branch) {
                     if ($branch && preg_match('{^(?:\* ) *(?:[^/ ]+?/)?(\S+) *[a-f0-9]+ .*$}', $branch, $match)) {
                         $version = 'dev-'.$match[1];
-                        if (isset($config['extra']['branch-alias'][$version])
-                            && substr($config['extra']['branch-alias'][$version], -4) === '-dev'
-                        ) {
-                            $targetBranch = $config['extra']['branch-alias'][$version];
-                            $normalized = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
-                            $version = preg_replace('{(\.9{7})+}', '.x', $normalized);
-                        }
                     }
                 }
             }
@@ -97,6 +91,16 @@ class RootPackageLoader extends ArrayLoader
             $package->setRepositories($config['repositories']);
         }
 
+        if (isset($config['extra']['branch-alias'][$version])
+            && substr($config['extra']['branch-alias'][$version], -4) === '-dev'
+        ) {
+            $targetBranch = $config['extra']['branch-alias'][$version];
+            $normalized = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
+            $version = preg_replace('{(\.9{7})+}', '.x', $normalized);
+
+            return new AliasPackage($package, $normalized, $version);
+        }
+
         return $package;
     }
 }