mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-02-06 06:39:58 +01:00
Prevent 404 in case the repository in empty, create a proper error. Fixes #305
This commit is contained in:
@@ -2,4 +2,7 @@
|
||||
|
||||
namespace GitList\Exception;
|
||||
|
||||
class BlankDataException extends \RuntimeException {}
|
||||
class BlankDataException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
8
src/GitList/Exception/EmptyRepositoryException.php
Normal file
8
src/GitList/Exception/EmptyRepositoryException.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace GitList\Exception;
|
||||
|
||||
class EmptyRepositoryException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace GitList\Util;
|
||||
|
||||
use Silex\Application;
|
||||
use GitList\Exception\EmptyRepositoryException;
|
||||
|
||||
class Routing
|
||||
{
|
||||
@@ -40,8 +41,6 @@ class Routing
|
||||
}
|
||||
|
||||
if ($commitish === null) {
|
||||
// DEBUG Can you have a repo with no branches? How should we handle
|
||||
// that?
|
||||
$branches = $repository->getBranches();
|
||||
|
||||
$tags = $repository->getTags();
|
||||
@@ -59,11 +58,11 @@ class Routing
|
||||
}
|
||||
}
|
||||
|
||||
$commitish = $matchedBranch;
|
||||
}
|
||||
if ($matchedBranch === null) {
|
||||
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.');
|
||||
}
|
||||
|
||||
if ($commitish === null) {
|
||||
$app->abort(404, "'$branch_path' does not appear to contain a commit-ish for '$repo'.");
|
||||
$commitish = $matchedBranch;
|
||||
}
|
||||
|
||||
$commitishLength = strlen($commitish);
|
||||
|
||||
Reference in New Issue
Block a user