Skip to content

Commit

Permalink
Internal refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jun 5, 2024
1 parent ab93da8 commit 9f893cc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Version/Persister/TagPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ public function getCurrentVersion(Context $context): string
// Extract versions from tags and sort them
$versions = $this->getVersionFromTags($tags, $context);

if ([] === $versions) {
throw new NoReleaseFoundException('No versions found in tag list');
}

usort($versions, [$context->versionGenerator, 'compareVersions']);

if ($this->versionedBranch) {
$branchVersions = $this->getPrefixedVersions($context, $versions);

Expand All @@ -62,6 +56,8 @@ public function getCurrentVersion(Context $context): string
}
}

\assert([] !== $versions);

return array_pop($versions);
}

Expand Down Expand Up @@ -102,10 +98,17 @@ private function getVersionFromTag(string $tagName, Context $context): string
private function getVersionFromTags(array $tags, Context $context): array
{
$versions = [];

foreach ($tags as $tag) {
$versions[] = $this->getVersionFromTag($tag, $context);
}

if ([] === $versions) {
throw new NoReleaseFoundException('No versions found in tag list');
}

usort($versions, [$context->versionGenerator, 'compareVersions']);

return $versions;
}

Expand Down

0 comments on commit 9f893cc

Please sign in to comment.