Fetch default HEAD branch from remote
parent
b6537324ef
commit
f2ab4d08e5
|
@ -12,6 +12,7 @@ class GitDriver implements VcsDriverInterface
|
||||||
protected $url;
|
protected $url;
|
||||||
protected $tags;
|
protected $tags;
|
||||||
protected $branches;
|
protected $branches;
|
||||||
|
protected $rootIdentifier;
|
||||||
protected $infoCache = array();
|
protected $infoCache = array();
|
||||||
|
|
||||||
public function __construct($url)
|
public function __construct($url)
|
||||||
|
@ -42,7 +43,18 @@ class GitDriver implements VcsDriverInterface
|
||||||
*/
|
*/
|
||||||
public function getRootIdentifier()
|
public function getRootIdentifier()
|
||||||
{
|
{
|
||||||
return 'master';
|
if (null === $this->rootIdentifier) {
|
||||||
|
$this->rootIdentifier = 'master';
|
||||||
|
exec(sprintf('cd %s && git branch --no-color -r', escapeshellarg($this->tmpDir)), $output);
|
||||||
|
foreach ($output as $key => $branch) {
|
||||||
|
if ($branch && preg_match('{/HEAD +-> +[^/]+/(\S+)}', $branch, $match)) {
|
||||||
|
$this->rootIdentifier = $match[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->rootIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +133,7 @@ class GitDriver implements VcsDriverInterface
|
||||||
|
|
||||||
exec(sprintf('cd %s && git branch --no-color -rv', escapeshellarg($this->tmpDir)), $output);
|
exec(sprintf('cd %s && git branch --no-color -rv', escapeshellarg($this->tmpDir)), $output);
|
||||||
foreach ($output as $key => $branch) {
|
foreach ($output as $key => $branch) {
|
||||||
if ($branch && !preg_match('{/HEAD }', $branch)) {
|
if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
|
||||||
preg_match('{^ *[^/]+/(\S+) *([a-f0-9]+) .*$}', $branch, $match);
|
preg_match('{^ *[^/]+/(\S+) *([a-f0-9]+) .*$}', $branch, $match);
|
||||||
$branches[$match[1]] = $match[2];
|
$branches[$match[1]] = $match[2];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue