Skip to content

Commit

Permalink
[#25] Invalid Version: [[]] when no tag can be found
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tomzx committed Jan 21, 2017
1 parent 7d6d183 commit de49bb7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ protected function findTag(Repository $repository, $tag)

$tagExpression = new SemanticExpression($tag);

return $this->getMappedVersionTag($tags, $tagExpression->maxSatisfying($tags));
try {
// Throws an exception if it cannot find a matching version
$satisfyingTag = $tagExpression->maxSatisfying($tags);
} catch (SemanticVersionException $e) {
return null;
}

return $this->getMappedVersionTag($tags, $satisfyingTag);
}

private function filterTags(array $tags)
Expand Down

0 comments on commit de49bb7

Please sign in to comment.