Update extgitgraph to affd4d10
This commit is contained in:
parent
9277ce1a65
commit
ae75d00fe2
48
www/extern/egg/RemoteSource.php
vendored
48
www/extern/egg/RemoteSource.php
vendored
@ -115,9 +115,10 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $reponame
|
* @param string $reponame
|
||||||
|
* @param int $page
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected abstract function queryBranches($reponame);
|
protected abstract function queryBranches($reponame, $page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $reponame
|
* @param string $reponame
|
||||||
@ -161,12 +162,17 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
$page = 1;
|
$page = 1;
|
||||||
$json = $this->queryRepositories($f[0], $page);
|
$json = $this->queryRepositories($f[0], $page);
|
||||||
|
|
||||||
|
$found = [];
|
||||||
while (! empty($json))
|
while (! empty($json))
|
||||||
{
|
{
|
||||||
|
$count = 0;
|
||||||
foreach ($json as $result_repo)
|
foreach ($json as $result_repo)
|
||||||
{
|
{
|
||||||
$jdata = $this->readRepository($result_repo);
|
$jdata = $this->readRepository($result_repo);
|
||||||
|
|
||||||
|
if (in_array($jdata['full_name'], $found)) continue;
|
||||||
|
$found []= $jdata['full_name'];
|
||||||
|
|
||||||
if (!Utils::isRepoFilterMatch($this->filter, $this->exclusions, $jdata['full_name']))
|
if (!Utils::isRepoFilterMatch($this->filter, $this->exclusions, $jdata['full_name']))
|
||||||
{
|
{
|
||||||
$this->logger->proclog("Skip Repo: " . $jdata['full_name']);
|
$this->logger->proclog("Skip Repo: " . $jdata['full_name']);
|
||||||
@ -178,6 +184,8 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
$result []= $db->getOrCreateRepository($jdata['html_url'], $jdata['full_name'], $this->name);
|
$result []= $db->getOrCreateRepository($jdata['html_url'], $jdata['full_name'], $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($count === 0) break;
|
||||||
|
|
||||||
$page++;
|
$page++;
|
||||||
$json = $this->queryRepositories($f[0], $page);
|
$json = $this->queryRepositories($f[0], $page);
|
||||||
}
|
}
|
||||||
@ -197,8 +205,13 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$json = $this->queryBranches($repo->Name);
|
$page = 1;
|
||||||
|
$json = $this->queryBranches($repo->Name, $page);
|
||||||
|
|
||||||
|
$found = [];
|
||||||
|
while (! empty($json))
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
foreach ($json as $result_branch) {
|
foreach ($json as $result_branch) {
|
||||||
$jdata = $this->readBranch($result_branch);
|
$jdata = $this->readBranch($result_branch);
|
||||||
|
|
||||||
@ -207,11 +220,21 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
$bname = $jdata['name'];
|
$bname = $jdata['name'];
|
||||||
$bhead = $jdata['sha'];
|
$bhead = $jdata['sha'];
|
||||||
|
|
||||||
|
if (in_array($bname, $found)) continue;
|
||||||
|
$found []= $bname;
|
||||||
|
|
||||||
$this->logger->proclog("Found Branch in Remote: [" . $repo->Name . "] " . $bname);
|
$this->logger->proclog("Found Branch in Remote: [" . $repo->Name . "] " . $bname);
|
||||||
|
|
||||||
$b = $db->getOrCreateBranch($this->name, $repo, $bname);
|
$b = $db->getOrCreateBranch($this->name, $repo, $bname);
|
||||||
$b->HeadFromAPI = $bhead;
|
$b->HeadFromAPI = $bhead;
|
||||||
$result []= $b;
|
$result []= $b;
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($count === 0) break;
|
||||||
|
|
||||||
|
$page++;
|
||||||
|
$json = $this->queryBranches($repo->Name, $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->deleteOtherBranches($this->name, $repo, $result);
|
$db->deleteOtherBranches($this->name, $repo, $result);
|
||||||
@ -337,7 +360,7 @@ class GithubConnection extends StandardGitConnection
|
|||||||
const API_RATELIMIT = 'https://api.github.com/rate_limit';
|
const API_RATELIMIT = 'https://api.github.com/rate_limit';
|
||||||
const API_REPOSITORIESLIST = 'https://api.github.com/users/{user}/repos?page={page}&per_page=100';
|
const API_REPOSITORIESLIST = 'https://api.github.com/users/{user}/repos?page={page}&per_page=100';
|
||||||
const API_COMMITSLIST = 'https://api.github.com/repos/{repo}/commits?per_page=100&sha={sha}';
|
const API_COMMITSLIST = 'https://api.github.com/repos/{repo}/commits?per_page=100&sha={sha}';
|
||||||
const API_BRANCHLIST = 'https://api.github.com/repos/{repo}/branches';
|
const API_BRANCHLIST = 'https://api.github.com/repos/{repo}/branches?page={page}';
|
||||||
|
|
||||||
/** @var string $url */
|
/** @var string $url */
|
||||||
private $url;
|
private $url;
|
||||||
@ -419,9 +442,9 @@ class GithubConnection extends StandardGitConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryBranches($reponame)
|
protected function queryBranches($reponame, $page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame]);
|
$url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame, 'page'=>$page]);
|
||||||
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,9 +506,9 @@ class GiteaConnection extends StandardGitConnection
|
|||||||
{
|
{
|
||||||
const API_BASE_URL = '/api/v1';
|
const API_BASE_URL = '/api/v1';
|
||||||
|
|
||||||
const API_USER_REPO_LIST = '/users/{user}/repos';
|
const API_USER_REPO_LIST = '/users/{user}/repos?page={page}&limit={limit}';
|
||||||
const API_BRANCH_LIST = '/repos/{repo}/branches';
|
const API_BRANCH_LIST = '/repos/{repo}/branches?page={page}&limit={limit}';
|
||||||
const API_COMMIT_LIST = '/repos/{repo}/commits?sha={sha}';
|
const API_COMMIT_LIST = '/repos/{repo}/commits?sha={sha}&limit={limit}';
|
||||||
|
|
||||||
/** @var string $url */
|
/** @var string $url */
|
||||||
private $url;
|
private $url;
|
||||||
@ -529,22 +552,21 @@ class GiteaConnection extends StandardGitConnection
|
|||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryRepositories($user, $page)
|
protected function queryRepositories($user, $page)
|
||||||
{
|
{
|
||||||
if ($page > 1) return [];
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_REPO_LIST), ['user'=>$user, 'page'=>$page, 'limit'=>64 ]);
|
||||||
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_REPO_LIST), ['user'=>$user ]);
|
|
||||||
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryBranches($reponame)
|
protected function queryBranches($reponame, $page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame]);
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame, 'page'=>$page, 'limit'=>64]);
|
||||||
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryCommits($reponame, $branchname, $startsha)
|
protected function queryCommits($reponame, $branchname, $startsha)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_COMMIT_LIST), [ 'repo'=>$reponame, 'sha'=>$startsha ]);
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_COMMIT_LIST), [ 'repo'=>$reponame, 'sha'=>$startsha, 'limit'=>1024 ]);
|
||||||
$this->logger->proclog("Query commits from: [" . $this->name . "|" . $reponame . "|" . $branchname . "] continuing at {" . substr($startsha, 0, 8) . "}");
|
$this->logger->proclog("Query commits from: [" . $this->name . "|" . $reponame . "|" . $branchname . "] continuing at {" . substr($startsha, 0, 8) . "}");
|
||||||
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user