Add a getter to fetch the repo data from the outside of the github driver
parent
0040498e25
commit
8bfb2e8bc2
|
@ -30,6 +30,7 @@ class GitHubDriver extends VcsDriver
|
||||||
protected $tags;
|
protected $tags;
|
||||||
protected $branches;
|
protected $branches;
|
||||||
protected $rootIdentifier;
|
protected $rootIdentifier;
|
||||||
|
protected $repoData;
|
||||||
protected $hasIssues;
|
protected $hasIssues;
|
||||||
protected $infoCache = array();
|
protected $infoCache = array();
|
||||||
protected $isPrivate = false;
|
protected $isPrivate = false;
|
||||||
|
@ -276,6 +277,18 @@ class GitHubDriver extends VcsDriver
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives back the loaded <github-api>/repos/<owner>/<repo> result
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public function getRepoData()
|
||||||
|
{
|
||||||
|
$this->fetchRootIdentifier();
|
||||||
|
|
||||||
|
return $this->repoData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an SSH URL
|
* Generate an SSH URL
|
||||||
*
|
*
|
||||||
|
@ -400,25 +413,29 @@ class GitHubDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
protected function fetchRootIdentifier()
|
protected function fetchRootIdentifier()
|
||||||
{
|
{
|
||||||
$repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
|
if ($this->repoData) {
|
||||||
|
|
||||||
$repoData = JsonFile::parseJson($this->getContents($repoDataUrl, true), $repoDataUrl);
|
|
||||||
if (null === $repoData && null !== $this->gitDriver) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->owner = $repoData['owner']['login'];
|
$repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
|
||||||
$this->repository = $repoData['name'];
|
|
||||||
|
|
||||||
$this->isPrivate = !empty($repoData['private']);
|
$this->repoData = JsonFile::parseJson($this->getContents($repoDataUrl, true), $repoDataUrl);
|
||||||
if (isset($repoData['default_branch'])) {
|
if (null === $this->repoData && null !== $this->gitDriver) {
|
||||||
$this->rootIdentifier = $repoData['default_branch'];
|
return;
|
||||||
} elseif (isset($repoData['master_branch'])) {
|
}
|
||||||
$this->rootIdentifier = $repoData['master_branch'];
|
|
||||||
|
$this->owner = $this->repoData['owner']['login'];
|
||||||
|
$this->repository = $this->repoData['name'];
|
||||||
|
|
||||||
|
$this->isPrivate = !empty($this->repoData['private']);
|
||||||
|
if (isset($this->repoData['default_branch'])) {
|
||||||
|
$this->rootIdentifier = $this->repoData['default_branch'];
|
||||||
|
} elseif (isset($this->repoData['master_branch'])) {
|
||||||
|
$this->rootIdentifier = $this->repoData['master_branch'];
|
||||||
} else {
|
} else {
|
||||||
$this->rootIdentifier = 'master';
|
$this->rootIdentifier = 'master';
|
||||||
}
|
}
|
||||||
$this->hasIssues = !empty($repoData['has_issues']);
|
$this->hasIssues = !empty($this->repoData['has_issues']);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function attemptCloneFallback()
|
protected function attemptCloneFallback()
|
||||||
|
|
Loading…
Reference in New Issue