From de49bb7dc33b00c99cbcb8ef2ab4bc75d28d8ec8 Mon Sep 17 00:00:00 2001 From: Tom Rochette Date: Sat, 21 Jan 2017 17:35:39 -0500 Subject: [PATCH] [#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. --- .../Console/Command/SuggestCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php b/src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php index 1ef4dec..eeb5478 100644 --- a/src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php +++ b/src/PHPSemVerCheckerGit/Console/Command/SuggestCommand.php @@ -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)