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) {
$commitish = $matchedBranch;
}
}
if ($commitish === null) {
// We may have partial commit hash as our commitish.
$hash = $slashPosition === false ? $commitishPath : substr($commitishPath, 0, $slashPosition);
if ($repository->hasCommit($hash)) {
$commit = $repository->getCommit($hash);
$commitish = $commit->getHash();
else
{
// We may have partial commit hash as our commitish.
$hash = $slashPosition === false ? $commitishPath : substr($commitishPath, 0, $slashPosition);
if ($repository->hasCommit($hash)) {
$commit = $repository->getCommit($hash);
$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);
$path = substr($commitishPath, $commitishLength);