From 22a81468d5126dbba550a9b06fc60c3214f000e5 Mon Sep 17 00:00:00 2001 From: Peter Droogmans Date: Wed, 27 Jun 2012 14:43:46 +0200 Subject: [PATCH] fix for #61, #62 --- controllers/treeController.php | 2 +- lib/Application/Utils.php | 4 ++-- lib/Git/Repository.php | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/treeController.php b/controllers/treeController.php index ab83001..bb470cc 100644 --- a/controllers/treeController.php +++ b/controllers/treeController.php @@ -17,7 +17,7 @@ $app->get('{repo}/', function($repo) use($app) { 'breadcrumbs' => $breadcrumbs, 'branches' => $repository->getBranches(), 'tags' => $repository->getTags(), - 'readme' => $app['utils']->getReadme($repo), + 'readme' => $app['utils']->getReadme($repo, $defaultBranch), )); })->assert('repo', '[\w-._]+'); diff --git a/lib/Application/Utils.php b/lib/Application/Utils.php index a35784f..46ef23c 100644 --- a/lib/Application/Utils.php +++ b/lib/Application/Utils.php @@ -249,7 +249,7 @@ class Utils public function getReadme($repo, $branch = 'master') { $repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo); - $files = $repository->getTree('master')->output(); + $files = $repository->getTree($branch)->output(); foreach ($files as $fileInfo) if (preg_match('/^readme*/i', $fileInfo['name'])) { @@ -257,4 +257,4 @@ class Utils } return array(); } -} \ No newline at end of file +} diff --git a/lib/Git/Repository.php b/lib/Git/Repository.php index dac7878..e1fa979 100644 --- a/lib/Git/Repository.php +++ b/lib/Git/Repository.php @@ -414,6 +414,9 @@ class Repository public function getHead() { $file = file_get_contents($this->getPath() . '/.git/HEAD'); + if ($file === FALSE) { + $file = file_get_contents($this->getPath() . '/HEAD'); + } foreach (explode("\n", $file) as $line) { $m = array(); if (preg_match('#ref:\srefs/heads/(.+)#', $line, $m)) {