1
0
Fork 0

Fix more issues with dev-master normalization in aliases

pull/8690/head
Jordi Boggiano 2020-03-13 13:52:16 +01:00
parent e09dd9c10d
commit 7cca451312
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 14 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -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;