Skip to content

Commit

Permalink
Ensure Latest Version updates only includes stable releases
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioheleno committed Mar 18, 2022
1 parent 45ff74d commit 176958a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function __construct(
/**
* Checks if the new version is higher than the package's current latest version,
* if it's, bumps the latest version.
*
* Note: only sets the latest version if it is stable
*/
public function __invoke(EventInterface $event): void {
$version = $event->getVersion();
Expand All @@ -48,12 +50,14 @@ public function __invoke(EventInterface $event): void {
$version->getPackageName()
);

$latestNormalizedVersion = '0.0.0.0';
$latestVersionNormalized = '0.0.0.0';
$latestVersionIsStable = false;
if ($package->getLatestVersion() !== '') {
$latestNormalizedVersion = $this->versionParser->normalize($package->getLatestVersion());
$latestVersionNormalized = $this->versionParser->normalize($package->getLatestVersion());
$latestVersionIsStable = VersionParser::parseStability($latestVersionNormalized) === 'stable';
}

if (Comparator::greaterThan($version->getNormalized(), $latestNormalizedVersion)) {
if ($latestVersionIsStable && Comparator::greaterThan($version->getNormalized(), $latestVersionNormalized)) {
$package = $package->withLatestVersion($version->getNumber());
$package = $this->packageRepository->update($package);

Expand Down

0 comments on commit 176958a

Please sign in to comment.