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 $branches;
|
||||
protected $rootIdentifier;
|
||||
protected $repoData;
|
||||
protected $hasIssues;
|
||||
protected $infoCache = array();
|
||||
protected $isPrivate = false;
|
||||
|
@ -276,6 +277,18 @@ class GitHubDriver extends VcsDriver
|
|||
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
|
||||
*
|
||||
|
@ -400,25 +413,29 @@ class GitHubDriver extends VcsDriver
|
|||
*/
|
||||
protected function fetchRootIdentifier()
|
||||
{
|
||||
$repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
|
||||
|
||||
$repoData = JsonFile::parseJson($this->getContents($repoDataUrl, true), $repoDataUrl);
|
||||
if (null === $repoData && null !== $this->gitDriver) {
|
||||
if ($this->repoData) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->owner = $repoData['owner']['login'];
|
||||
$this->repository = $repoData['name'];
|
||||
$repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
|
||||
|
||||
$this->isPrivate = !empty($repoData['private']);
|
||||
if (isset($repoData['default_branch'])) {
|
||||
$this->rootIdentifier = $repoData['default_branch'];
|
||||
} elseif (isset($repoData['master_branch'])) {
|
||||
$this->rootIdentifier = $repoData['master_branch'];
|
||||
$this->repoData = JsonFile::parseJson($this->getContents($repoDataUrl, true), $repoDataUrl);
|
||||
if (null === $this->repoData && null !== $this->gitDriver) {
|
||||
return;
|
||||
}
|
||||
|
||||
$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 {
|
||||
$this->rootIdentifier = 'master';
|
||||
}
|
||||
$this->hasIssues = !empty($repoData['has_issues']);
|
||||
$this->hasIssues = !empty($this->repoData['has_issues']);
|
||||
}
|
||||
|
||||
protected function attemptCloneFallback()
|
||||
|
|
Loading…
Reference in New Issue