Shorter and less condition

This commit is contained in:
Samuel Lemaitre
2014-05-14 16:11:37 +02:00
parent 16810bcaf3
commit 851a0dfb0e

View File

@@ -61,20 +61,19 @@ class Routing
if ($matchedBranch !== null) { if ($matchedBranch !== null) {
$commitish = $matchedBranch; $commitish = $matchedBranch;
} }
} else
{
if ($commitish === null) { // We may have partial commit hash as our commitish.
// We may have partial commit hash as our commitish. $hash = $slashPosition === false ? $commitishPath : substr($commitishPath, 0, $slashPosition);
$hash = $slashPosition === false ? $commitishPath : substr($commitishPath, 0, $slashPosition); if ($repository->hasCommit($hash)) {
if ($repository->hasCommit($hash)) { $commit = $repository->getCommit($hash);
$commit = $repository->getCommit($hash); $commitish = $commit->getHash();
$commitish = $commit->getHash(); }
else
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.');
} }
} }
if ($commitish === null) {
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.');
}
$commitishLength = strlen($commitish); $commitishLength = strlen($commitish);
$path = substr($commitishPath, $commitishLength); $path = substr($commitishPath, $commitishLength);