Merge pull request #456 from mikedld/support-partial-commit-hash

Treat possible commit as partial hash as fallback.
This commit is contained in:
Klaus Silveira
2014-05-17 10:32:13 -03:00

View File

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