mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
@@ -17,7 +17,7 @@ $app->get('{repo}/', function($repo) use($app) {
|
|||||||
'breadcrumbs' => $breadcrumbs,
|
'breadcrumbs' => $breadcrumbs,
|
||||||
'branches' => $repository->getBranches(),
|
'branches' => $repository->getBranches(),
|
||||||
'tags' => $repository->getTags(),
|
'tags' => $repository->getTags(),
|
||||||
'readme' => $app['utils']->getReadme($repo),
|
'readme' => $app['utils']->getReadme($repo, $defaultBranch),
|
||||||
));
|
));
|
||||||
})->assert('repo', '[\w-._]+');
|
})->assert('repo', '[\w-._]+');
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ class Utils
|
|||||||
public function getReadme($repo, $branch = 'master')
|
public function getReadme($repo, $branch = 'master')
|
||||||
{
|
{
|
||||||
$repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo);
|
$repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo);
|
||||||
$files = $repository->getTree('master')->output();
|
$files = $repository->getTree($branch)->output();
|
||||||
|
|
||||||
foreach ($files as $fileInfo)
|
foreach ($files as $fileInfo)
|
||||||
if (preg_match('/^readme*/i', $fileInfo['name'])) {
|
if (preg_match('/^readme*/i', $fileInfo['name'])) {
|
||||||
@@ -257,4 +257,4 @@ class Utils
|
|||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,6 +414,9 @@ class Repository
|
|||||||
public function getHead()
|
public function getHead()
|
||||||
{
|
{
|
||||||
$file = file_get_contents($this->getPath() . '/.git/HEAD');
|
$file = file_get_contents($this->getPath() . '/.git/HEAD');
|
||||||
|
if ($file === FALSE) {
|
||||||
|
$file = file_get_contents($this->getPath() . '/HEAD');
|
||||||
|
}
|
||||||
foreach (explode("\n", $file) as $line) {
|
foreach (explode("\n", $file) as $line) {
|
||||||
$m = array();
|
$m = array();
|
||||||
if (preg_match('#ref:\srefs/heads/(.+)#', $line, $m)) {
|
if (preg_match('#ref:\srefs/heads/(.+)#', $line, $m)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user