mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Merge pull request #79 from attiks/betterHeads
better Head detection if refs/heads is pointing to non-existing master
This commit is contained in:
@@ -388,7 +388,7 @@ class Repository
|
|||||||
|
|
||||||
public function getAuthorStatistics()
|
public function getAuthorStatistics()
|
||||||
{
|
{
|
||||||
$logs = $this->getClient()->run($this, 'log --pretty=format:\'%an||%ae\'');
|
$logs = $this->getClient()->run($this, 'log --pretty=format:\'%an||%ae\' ' . $this->getHead());
|
||||||
|
|
||||||
if (empty($logs)) {
|
if (empty($logs)) {
|
||||||
throw new \RuntimeException('No statistics available');
|
throw new \RuntimeException('No statistics available');
|
||||||
@@ -422,14 +422,21 @@ class Repository
|
|||||||
else {
|
else {
|
||||||
return 'master';
|
return 'master';
|
||||||
}
|
}
|
||||||
|
// Find first existing branch
|
||||||
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)) {
|
||||||
return $m[1];
|
if ($this->hasBranch($m[1])) {
|
||||||
|
return $m[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to something sane if in a detached HEAD state.
|
// Default to something sane if in a detached HEAD state.
|
||||||
|
$branches = $this->getBranches();
|
||||||
|
if (!empty($branches)) {
|
||||||
|
return current($branches);
|
||||||
|
}
|
||||||
return 'master';
|
return 'master';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user