Skip to content

Commit

Permalink
Merge pull request #287 from vtsykun/fix/dev-version
Browse files Browse the repository at this point in the history
Fix PR use first non development version as download if possible
  • Loading branch information
vtsykun authored Nov 2, 2024
2 parents 0bc2803 + a659948 commit a45a742
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Entity/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,15 @@ public function getVersions()

public function getVersionByReference(string $reference): ?Version
{
return $this->versions->findFirst(fn($k, $v) => $v->getReference() === $reference);
$matchedVersions = $this->versions->filter(static fn(Version $v) => $v->getReference() === $reference);

foreach ($matchedVersions as $matchedVersion) {
if ($matchedVersion->isDevelopment() === false) {
return $matchedVersion;
}
}

return $matchedVersions->first() ?: null;
}

/**
Expand Down

0 comments on commit a45a742

Please sign in to comment.