1
0

added extendedgitgraph_refresh php cli-script

This commit is contained in:
Mike Schwörer 2022-10-16 15:53:52 +02:00
parent cb22029f7e
commit 8186165019
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
5 changed files with 64 additions and 10 deletions

View File

@ -329,7 +329,7 @@ abstract class StandardGitConnection implements IRemoteSource
$json = $this->queryCommits($repo->Name, $branch->Name, $next_sha[0]);
}
$this->logger->proclog("HEAD pointer in Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] no longer matches. Re-query all " . count($newcommits) . " commits (old HEAD := {".substr($branch->Head, 0, 8)."}, missing: [" . join(", ", array_map(function($p){return substr($p, 0, 8);}, $next_sha)) . "] )");
$this->logger->proclog("HEAD pointer in Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] no longer matches. Re-query all " . count($newcommits) . " commits (old HEAD := {".substr($branch->Head ?? 'NULL', 0, 8)."}, missing: [" . join(", ", array_map(function($p){return substr($p ?? 'NULL', 0, 8);}, $next_sha)) . "] )");
$db->deleteAllCommits($branch);

View File

@ -81,7 +81,7 @@ class Modules
public function ExtendedGitGraph(): MikescherGitGraph
{
if ($this->extendedgitgraph === null) { require_once 'modules/mikeschergitgraph.php'; $this->extendedgitgraph = new MikescherGitGraph($this->site); }
if ($this->extendedgitgraph === null) { require_once 'modules/mikeschergitgraph.php'; $this->extendedgitgraph = new MikescherGitGraph($this->site->config['extendedgitgraph']); }
return $this->extendedgitgraph;
}

View File

@ -1,29 +1,30 @@
<?php
require_once (__DIR__ . '/../../extern/egg/ExtendedGitGraph2.php');
require_once (__DIR__ . '/../iwebsitemodule.php');
class MikescherGitGraph implements IWebsiteModule
{
/** @var ExtendedGitGraph2 */
private $extgitgraph;
private ExtendedGitGraph2 $extgitgraph;
/** @noinspection PhpUnhandledExceptionInspection */
public function __construct(Website $site)
public function __construct(array $egh_conf)
{
$this->extgitgraph = new ExtendedGitGraph2($site->config['extendedgitgraph']);
$this->extgitgraph = new ExtendedGitGraph2($egh_conf);
}
public function getPathRenderedData()
public function getPathRenderedData(): string
{
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
}
public function update()
public function update(): bool
{
return $this->extgitgraph->update();
}
public function updateCache()
public function updateCache(): ?string
{
return $this->extgitgraph->updateCache();
}
@ -31,14 +32,14 @@ class MikescherGitGraph implements IWebsiteModule
/**
* @return string|null
*/
public function get()
public function get(): ?string
{
$d = $this->extgitgraph->loadFromCache();
if ($d === null) return "";
return $d;
}
public function checkConsistency()
public function checkConsistency(): array
{
$p = $this->getPathRenderedData();

1
www/shell/.htaccess Normal file
View File

@ -0,0 +1 @@
Deny from all

View File

@ -0,0 +1,52 @@
#!/usr/bin/php
<?php
if (php_sapi_name() !== "cli") die("[cli only!]");
set_time_limit(6*60*60); // 6h
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
error_reporting(E_ALL);
echo "\n";
echo "==================================== Init ====================================\n";
echo "\n";
$config = (require (__DIR__ . '/../config.php'))['extendedgitgraph'];
$config['output_session'] = false;
$config['output_file'] = false;
$config['output_stdout'] = true;
require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php';
$egg = new MikescherGitGraph($config);
echo "\n";
echo "================================ Start Update ================================\n";
echo "\n";
$r1 = $egg->update();
if (!$r1)
{
echo "EGG::update failed.\n";
exit(99);
}
echo "\n";
echo "============================= Start Update-Cache =============================\n";
echo "\n";
$r2 = $egg->updateCache();
if (!$r2)
{
echo "EGG::updateCache failed.";
exit(99);
}
echo "\n";
echo "==============================================================================\n";
echo "\n";
echo "Done.\n";
exit(0);