Skip to content

Commit de49bb7

Browse files
committed
[#25] Invalid Version: [[]] when no tag can be found
If no matching tag can be found, the semver library still attempts to create a tag with the string "". This in turn generates an exception, which is now caught, and we return null to indicate that no tag was found.
1 parent 7d6d183 commit de49bb7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ protected function findTag(Repository $repository, $tag)
184184

185185
$tagExpression = new SemanticExpression($tag);
186186

187-
return $this->getMappedVersionTag($tags, $tagExpression->maxSatisfying($tags));
187+
try {
188+
// Throws an exception if it cannot find a matching version
189+
$satisfyingTag = $tagExpression->maxSatisfying($tags);
190+
} catch (SemanticVersionException $e) {
191+
return null;
192+
}
193+
194+
return $this->getMappedVersionTag($tags, $satisfyingTag);
188195
}
189196

190197
private function filterTags(array $tags)

0 commit comments

Comments
 (0)