Skip to content

Commit

Permalink
Fix no stable release sorting bug (#617)
Browse files Browse the repository at this point in the history
* Fix no stable release sorting bug

* Try with Composer 1

* Fix assertion

* Fix buddy yaml

---------

Co-authored-by: Marick <[email protected]>
Co-authored-by: Arkadiusz Kondas <[email protected]>
  • Loading branch information
3 people authored Apr 30, 2023
1 parent b463a21 commit de1f2c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ public function synchronize(Package $package): void
return $a->getReleaseDate() <=> $b->getReleaseDate();
}

if ($a->getStability() === Version::STABILITY_STABLE && $b->getStability() !== Version::STABILITY_STABLE) {
return -1;
}

if ($a->getStability() !== Version::STABILITY_STABLE && $b->getStability() === Version::STABILITY_STABLE) {
return 1;
}

return Comparator::greaterThan($a->getVersion(), $b->getVersion()) ? 1 : -1;
});

Expand Down
Binary file not shown.
Binary file added tests/Resources/artifacts-mixed-sorting/b-1.0.0.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ public function testSynchronizePackageFromArtifacts(): void
self::assertContains('suggests-buddy-works/suggests-You really should', $linkStrings);
}

public function testWithMostRecentUnstable(): void
{
$this->downloader->addContent($this->resourcesDir.'artifacts-mixed-sorting', 'foobar');
$package = PackageMother::withOrganization('artifact', $this->resourcesDir.'artifacts-mixed-sorting', 'buddy');
$this->synchronizer->synchronize($package);

self::assertEquals('v1.0.0', $this->getProperty($package, 'latestReleasedVersion'));
}

public function testSynchronizePackageThatAlreadyExists(): void
{
$path = $this->baseDir.'/buddy/p/buddy-works/alpha.json';
Expand Down

0 comments on commit de1f2c3

Please sign in to comment.