This commit is contained in:
Peter Droogmans
2012-06-27 14:43:46 +02:00
parent ec2e12dc04
commit 22a81468d5
3 changed files with 6 additions and 3 deletions

View File

@@ -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-._]+');

View File

@@ -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'])) {

View File

@@ -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)) {