Skip to content

Commit

Permalink
Load root packages as aliases if they are aliased so that they replac…
Browse files Browse the repository at this point in the history
…e everything
  • Loading branch information
Seldaek committed Apr 29, 2012
1 parent f3df477 commit a4c2337
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Composer/Package/Loader/RootPackageLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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
Expand Down Expand Up @@ -48,13 +49,6 @@ public function load($config)
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);
}
}
}
}
Expand Down Expand Up @@ -97,6 +91,16 @@ public function load($config)
$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;
}
}

0 comments on commit a4c2337

Please sign in to comment.