Added fetchLimit overrides to EGG
This commit is contained in:
26
www/extern/egg/ExtendedGitGraph2.php
vendored
26
www/extern/egg/ExtendedGitGraph2.php
vendored
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'IConfigSource.php';
|
||||||
require_once 'Logger.php';
|
require_once 'Logger.php';
|
||||||
require_once 'EGGException.php';
|
require_once 'EGGException.php';
|
||||||
require_once 'RemoteSource.php';
|
require_once 'RemoteSource.php';
|
||||||
@@ -9,9 +10,9 @@ require_once 'OutputGenerator.php';
|
|||||||
require_once 'EGGDatabase.php';
|
require_once 'EGGDatabase.php';
|
||||||
require_once 'Utils.php';
|
require_once 'Utils.php';
|
||||||
|
|
||||||
class ExtendedGitGraph2 implements ILogger
|
class ExtendedGitGraph2 implements ILogger, IConfigSource
|
||||||
{
|
{
|
||||||
/** @var ILogger[] **/
|
/** @var ILogger[] **/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/** @var IRemoteSource[] **/
|
/** @var IRemoteSource[] **/
|
||||||
@@ -23,6 +24,11 @@ class ExtendedGitGraph2 implements ILogger
|
|||||||
/** @var EGGDatabase **/
|
/** @var EGGDatabase **/
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
|
public int $fetchLimitCommits = 1024;
|
||||||
|
public int $fetchLimitBranches = 64;
|
||||||
|
public int $fetchLimitRepos = 64;
|
||||||
|
public int $fetchLimitOrgs = 64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -33,7 +39,12 @@ class ExtendedGitGraph2 implements ILogger
|
|||||||
if ($config['output_session']) $this->logger []= new SessionLogger($config['session_var']);
|
if ($config['output_session']) $this->logger []= new SessionLogger($config['session_var']);
|
||||||
if ($config['output_stdout']) $this->logger []= new OutputLogger();
|
if ($config['output_stdout']) $this->logger []= new OutputLogger();
|
||||||
if ($config['output_logfile']) $this->logger []= new FileLogger($config['logfile'], $config['logfile_count']);
|
if ($config['output_logfile']) $this->logger []= new FileLogger($config['logfile'], $config['logfile_count']);
|
||||||
if ($config['output_file']) $this->logger []= new SingleFileLogger($config['output_filepath']);
|
if ($config['output_file']) $this->logger []= new SingleFileLogger($config['output_filepath']);
|
||||||
|
|
||||||
|
if (isset($config['fetchlimit_commits'])) $this->fetchLimitCommits = intval($config['fetchlimit_commits']);
|
||||||
|
if (isset($config['fetchlimit_branches'])) $this->fetchLimitBranches = intval($config['fetchlimit_branches']);
|
||||||
|
if (isset($config['fetchlimit_repos'])) $this->fetchLimitRepos = intval($config['fetchlimit_repos']);
|
||||||
|
if (isset($config['fetchlimit_orgs'])) $this->fetchLimitOrgs = intval($config['fetchlimit_orgs']);
|
||||||
|
|
||||||
$this->sources = [];
|
$this->sources = [];
|
||||||
|
|
||||||
@@ -42,9 +53,9 @@ class ExtendedGitGraph2 implements ILogger
|
|||||||
{
|
{
|
||||||
$newsrc = null;
|
$newsrc = null;
|
||||||
if ($rmt['type'] === 'github')
|
if ($rmt['type'] === 'github')
|
||||||
$newsrc = new GithubConnection($this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['oauth_id'], $rmt['oauth_secret'], $rmt['token_cache'] );
|
$newsrc = new GithubConnection($this, $this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['oauth_id'], $rmt['oauth_secret'], $rmt['token_cache'] );
|
||||||
else if ($rmt['type'] === 'gitea')
|
else if ($rmt['type'] === 'gitea')
|
||||||
$newsrc = new GiteaConnection($this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['username'], $rmt['password'] );
|
$newsrc = new GiteaConnection($this, $this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['username'], $rmt['password'] );
|
||||||
else
|
else
|
||||||
throw new EGGException("Unknown remote-type: " . $rmt['type']);
|
throw new EGGException("Unknown remote-type: " . $rmt['type']);
|
||||||
|
|
||||||
@@ -59,6 +70,11 @@ class ExtendedGitGraph2 implements ILogger
|
|||||||
$this->outputter = new FullRenderer($this, $config['identities'], $config['output_cache_files']);
|
$this->outputter = new FullRenderer($this, $config['identities'], $config['output_cache_files']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFetchLimitCommits(): int { return $this->fetchLimitCommits; }
|
||||||
|
public function getFetchLimitBranches(): int { return $this->fetchLimitBranches; }
|
||||||
|
public function getFetchLimitRepos(): int { return $this->fetchLimitRepos; }
|
||||||
|
public function getFetchLimitOrgs(): int { return $this->fetchLimitOrgs; }
|
||||||
|
|
||||||
public function update()
|
public function update()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
9
www/extern/egg/IConfigSource.php
vendored
Normal file
9
www/extern/egg/IConfigSource.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
interface IConfigSource
|
||||||
|
{
|
||||||
|
public function getFetchLimitCommits(): int;
|
||||||
|
public function getFetchLimitBranches(): int;
|
||||||
|
public function getFetchLimitRepos(): int;
|
||||||
|
public function getFetchLimitOrgs(): int;
|
||||||
|
}
|
||||||
2
www/extern/egg/Logger.php
vendored
2
www/extern/egg/Logger.php
vendored
@@ -4,7 +4,7 @@ require_once 'Utils.php';
|
|||||||
|
|
||||||
interface ILogger
|
interface ILogger
|
||||||
{
|
{
|
||||||
public function proclog($text);
|
public function proclog($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileLogger implements ILogger
|
class FileLogger implements ILogger
|
||||||
|
|||||||
18
www/extern/egg/RemoteSource.php
vendored
18
www/extern/egg/RemoteSource.php
vendored
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'IConfigSource.php';
|
||||||
require_once 'Utils.php';
|
require_once 'Utils.php';
|
||||||
require_once 'EGGDatabase.php';
|
require_once 'EGGDatabase.php';
|
||||||
|
|
||||||
@@ -18,8 +19,11 @@ interface IRemoteSource
|
|||||||
abstract class StandardGitConnection implements IRemoteSource
|
abstract class StandardGitConnection implements IRemoteSource
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var ILogger $logger */
|
/** @var ILogger $logger */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
|
/** @var IConfigSource $cfgSource */
|
||||||
|
protected $cfgSource;
|
||||||
|
|
||||||
/** @var string $name */
|
/** @var string $name */
|
||||||
protected $name;
|
protected $name;
|
||||||
@@ -31,14 +35,16 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
protected $exclusions;
|
protected $exclusions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ILogger $logger
|
* @param ILogger $logger
|
||||||
* @param string $name
|
* @param IConfigSource $cfg
|
||||||
|
* @param string $name
|
||||||
* @param string $filter
|
* @param string $filter
|
||||||
* @param string[] exclusions
|
* @param string[] exclusions
|
||||||
*/
|
*/
|
||||||
public function __construct(ILogger $logger, string $name, string $filter, array $exclusions)
|
public function __construct(ILogger $logger, IConfigSource $cfg, string $name, string $filter, array $exclusions)
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->cfgSource = $cfg;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->filter = $filter;
|
$this->filter = $filter;
|
||||||
$this->exclusions = $exclusions;
|
$this->exclusions = $exclusions;
|
||||||
|
|||||||
13
www/extern/egg/RemoteSourceGitea.php
vendored
13
www/extern/egg/RemoteSourceGitea.php
vendored
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'IConfigSource.php';
|
||||||
require_once 'Utils.php';
|
require_once 'Utils.php';
|
||||||
require_once 'EGGDatabase.php';
|
require_once 'EGGDatabase.php';
|
||||||
require_once 'RemoteSource.php';
|
require_once 'RemoteSource.php';
|
||||||
@@ -31,9 +32,9 @@ class GiteaConnection extends StandardGitConnection
|
|||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*/
|
*/
|
||||||
public function __construct(ILogger $logger, string $name, string $url, string $filter, array $exclusions, string $username, string $password)
|
public function __construct(ILogger $logger, IConfigSource $cfg, string $name, string $url, string $filter, array $exclusions, string $username, string $password)
|
||||||
{
|
{
|
||||||
parent::__construct($logger, $name, $filter, $exclusions);
|
parent::__construct($logger, $cfg, $name, $filter, $exclusions);
|
||||||
|
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
@@ -55,28 +56,28 @@ class GiteaConnection extends StandardGitConnection
|
|||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryOrganizations($page)
|
protected function queryOrganizations($page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_ORG_LIST), ['page'=>$page, 'limit'=>64 ]);
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_ORG_LIST), ['page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitOrgs() ]);
|
||||||
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryRepositories($user, $page)
|
protected function queryRepositories($user, $page)
|
||||||
{
|
{
|
||||||
$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, 'page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitRepos() ]);
|
||||||
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, $page)
|
protected function queryBranches($reponame, $page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame, 'page'=>$page, 'limit'=>64]);
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame, 'page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitBranches()]);
|
||||||
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, 'limit'=>1024 ]);
|
$url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_COMMIT_LIST), [ 'repo'=>$reponame, 'sha'=>$startsha, 'limit'=>$this->cfgSource->getFetchLimitCommits() ]);
|
||||||
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
www/extern/egg/RemoteSourceGithub.php
vendored
11
www/extern/egg/RemoteSourceGithub.php
vendored
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'IConfigSource.php';
|
||||||
require_once 'Utils.php';
|
require_once 'Utils.php';
|
||||||
require_once 'EGGDatabase.php';
|
require_once 'EGGDatabase.php';
|
||||||
require_once 'RemoteSource.php';
|
require_once 'RemoteSource.php';
|
||||||
@@ -39,9 +40,9 @@ class GithubConnection extends StandardGitConnection
|
|||||||
* @param string $oauth_secret
|
* @param string $oauth_secret
|
||||||
* @param string $apitokenpath
|
* @param string $apitokenpath
|
||||||
*/
|
*/
|
||||||
public function __construct(ILogger $logger, string $name, string $url, string $filter, array $exclusions, string $oauth_id, string $oauth_secret, string $apitokenpath)
|
public function __construct(ILogger $logger, IConfigSource $cfg, string $name, string $url, string $filter, array $exclusions, string $oauth_id, string $oauth_secret, string $apitokenpath)
|
||||||
{
|
{
|
||||||
parent::__construct($logger, $name, $filter, $exclusions);
|
parent::__construct($logger, $cfg, $name, $filter, $exclusions);
|
||||||
|
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
$this->oauth_id = $oauth_id;
|
$this->oauth_id = $oauth_id;
|
||||||
@@ -95,21 +96,21 @@ class GithubConnection extends StandardGitConnection
|
|||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryRepositories($user, $page)
|
protected function queryRepositories($user, $page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(self::API_REPOSITORIESLIST, ['user'=>$user, 'page'=>$page]);
|
$url = Utils::sharpFormat(self::API_REPOSITORIESLIST, ['user'=>$user, 'page'=>$page, 'per_page'=>$this->cfgSource->getFetchLimitRepos() ]);
|
||||||
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryBranches($reponame, $page)
|
protected function queryBranches($reponame, $page)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame, 'page'=>$page]);
|
$url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame, 'page'=>$page, 'per_page'=>$this->cfgSource->getFetchLimitBranches() ]);
|
||||||
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
protected function queryCommits($reponame, $branchname, $startsha)
|
protected function queryCommits($reponame, $branchname, $startsha)
|
||||||
{
|
{
|
||||||
$url = Utils::sharpFormat(self::API_COMMITSLIST, [ 'repo'=>$reponame, 'sha'=>$startsha ]);
|
$url = Utils::sharpFormat(self::API_COMMITSLIST, [ 'repo'=>$reponame, 'sha'=>$startsha, 'per_page'=>$this->cfgSource->getFetchLimitCommits() ]);
|
||||||
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class MikescherGitGraph implements IWebsiteModule
|
|||||||
$this->extgitgraph = new ExtendedGitGraph2($egh_conf);
|
$this->extgitgraph = new ExtendedGitGraph2($egh_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFetchLimitCommits(int $flo)
|
||||||
|
{
|
||||||
|
$this->extgitgraph->fetchLimitCommits = $flo;
|
||||||
|
}
|
||||||
|
|
||||||
public function getPathRenderedData(): string
|
public function getPathRenderedData(): string
|
||||||
{
|
{
|
||||||
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
|
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
|
||||||
|
|||||||
@@ -21,10 +21,18 @@ try {
|
|||||||
$config['output_file'] = false;
|
$config['output_file'] = false;
|
||||||
$config['output_stdout'] = true;
|
$config['output_stdout'] = true;
|
||||||
|
|
||||||
|
echo "ENV:\n" . print_r($_ENV, true) . "\n";
|
||||||
|
|
||||||
require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php';
|
require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php';
|
||||||
|
|
||||||
$egg = new MikescherGitGraph($config);
|
$egg = new MikescherGitGraph($config);
|
||||||
|
|
||||||
|
if (getenv('EGG_FETCHLIMITCOMMITS')) {
|
||||||
|
$v = intval(getenv('EGG_FETCHLIMITCOMMITS'));
|
||||||
|
$egg->setFetchLimitCommits($v);
|
||||||
|
echo "[*] EGG_FETCHLIMITCOMMITS override detected: $v\n";}
|
||||||
|
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo "================================ Start Update ================================\n";
|
echo "================================ Start Update ================================\n";
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user