|
|
|
@ -198,12 +198,17 @@ class GitHubDriver extends VcsDriver
|
|
|
|
|
return $this->gitDriver->getTags();
|
|
|
|
|
}
|
|
|
|
|
if (null === $this->tags) {
|
|
|
|
|
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags';
|
|
|
|
|
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
|
|
|
$this->tags = array();
|
|
|
|
|
foreach ($tagsData as $tag) {
|
|
|
|
|
$this->tags[$tag['name']] = $tag['commit']['sha'];
|
|
|
|
|
}
|
|
|
|
|
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
|
|
|
foreach ($tagsData as $tag) {
|
|
|
|
|
$this->tags[$tag['name']] = $tag['commit']['sha'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$resource = $this->getNextPage();
|
|
|
|
|
} while ($resource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->tags;
|
|
|
|
@ -218,13 +223,18 @@ class GitHubDriver extends VcsDriver
|
|
|
|
|
return $this->gitDriver->getBranches();
|
|
|
|
|
}
|
|
|
|
|
if (null === $this->branches) {
|
|
|
|
|
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads';
|
|
|
|
|
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
|
|
|
$this->branches = array();
|
|
|
|
|
foreach ($branchData as $branch) {
|
|
|
|
|
$name = substr($branch['ref'], 11);
|
|
|
|
|
$this->branches[$name] = $branch['object']['sha'];
|
|
|
|
|
}
|
|
|
|
|
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
|
|
|
foreach ($branchData as $branch) {
|
|
|
|
|
$name = substr($branch['ref'], 11);
|
|
|
|
|
$this->branches[$name] = $branch['object']['sha'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$resource = $this->getNextPage();
|
|
|
|
|
} while ($resource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->branches;
|
|
|
|
@ -428,4 +438,19 @@ class GitHubDriver extends VcsDriver
|
|
|
|
|
);
|
|
|
|
|
$this->gitDriver->initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getNextPage()
|
|
|
|
|
{
|
|
|
|
|
$headers = $this->remoteFilesystem->getLastHeaders();
|
|
|
|
|
foreach ($headers as $header) {
|
|
|
|
|
if (substr($header, 0, 5) === 'Link:') {
|
|
|
|
|
$links = explode(',', substr($header, 5));
|
|
|
|
|
foreach ($links as $link) {
|
|
|
|
|
if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
|
|
|
|
|
return $match[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|