Skip to content

Commit

Permalink
bug #699 Avoid filtering out aliases of valid packages (Seldaek)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.8-dev branch.

Discussion
----------

Avoid filtering out aliases of valid packages

It'd be good to add tests for this ... and I am not sure if the branch-alias check at line 67/68 is still needed if aliases are handled properly, might be or might not be.. I don't fully grasp the scope of what flex does here.

Commits
-------

27de569 Avoid filtering out aliases of valid packages
  • Loading branch information
nicolas-grekas committed Oct 14, 2020
2 parents 1cc7023 + 27de569 commit 277e060
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/PackageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Flex;

use Composer\IO\IOInterface;
use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\VersionParser;
Expand Down Expand Up @@ -54,20 +55,25 @@ public function removeLegacyPackages(array $data): array
$oneSymfony = false;
foreach ($data as $package) {
$name = $package->getName();
$version = $package->getVersion();
$versions = [$package->getVersion()];
if ($package instanceof AliasPackage) {
$versions[] = $package->getAliasOf()->getVersion();
}
if ('symfony/symfony' !== $name && !isset($knownVersions['splits'][$name])) {
$filteredPackages[] = $package;
continue;
}

if (null !== $alias = $package->getExtra()['branch-alias'][$version] ?? null) {
$version = $this->versionParser->normalize($alias);
if (null !== $alias = $package->getExtra()['branch-alias'][$package->getVersion()] ?? null) {
$versions[] = $this->versionParser->normalize($alias);
}

if ($this->symfonyConstraints->matches(new Constraint('==', $version))) {
$filteredPackages[] = $package;
$oneSymfony = $oneSymfony || 'symfony/symfony' === $name;
continue;
foreach ($versions as $version) {
if ($this->symfonyConstraints->matches(new Constraint('==', $version))) {
$filteredPackages[] = $package;
$oneSymfony = $oneSymfony || 'symfony/symfony' === $name;
continue 2;
}
}

if ('symfony/symfony' === $name) {
Expand Down

0 comments on commit 277e060

Please sign in to comment.