Treat possible commit as partial hash as fallback.

This commit is contained in:
Mike Gelfand
2014-05-14 15:03:28 +03:00
parent ff951124b6
commit 16810bcaf3

View File

@@ -58,11 +58,22 @@ class Routing
} }
} }
if ($matchedBranch === null) { if ($matchedBranch !== null) {
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.'); $commitish = $matchedBranch;
}
} }
$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();
}
}
if ($commitish === null) {
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.');
} }
$commitishLength = strlen($commitish); $commitishLength = strlen($commitish);