From: Christian Weiske Date: Wed, 19 Apr 2017 16:33:22 +0000 (+0200) Subject: Do not crash list view when seeing a fully empty git repository X-Git-Tag: v0.8.0~5 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/ade89bd51686796f30dc26b0f5c65eb9b6f66f21?hp=8a4d28fa14e4b0053d5fb9753535124b6bcbfe5e Do not crash list view when seeing a fully empty git repository This is not a good way to handle it, but makes phorkie more resilient against invalid data. Resolves: https://github.com/cweiske/phorkie/issues/24 --- diff --git a/src/phorkie/Repositories.php b/src/phorkie/Repositories.php index 729ff23..ab97c56 100644 --- a/src/phorkie/Repositories.php +++ b/src/phorkie/Repositories.php @@ -65,7 +65,16 @@ class Repositories $repos = array(); foreach ($some as $oneDir) { $r = new Repository(); - $r->loadById(substr($oneDir, 0, -4)); + try { + $r->loadById(substr($oneDir, 0, -4)); + } catch (\VersionControl_Git_Exception $e) { + if (strpos($e->getMessage(), 'does not have any commits') !== false) { + //the git repo is broken as the initial commit + // has not been finished + continue; + } + throw $e; + } $repos[] = $r; } return array($repos, count($dirs), $page);