Fix egg:deleteDanglingCommitdata()
This commit is contained in:
parent
8ed58917ff
commit
18af582343
14
www/extern/egg/EGGDatabase.php
vendored
14
www/extern/egg/EGGDatabase.php
vendored
@ -355,11 +355,19 @@ class EGGDatabase
|
|||||||
|
|
||||||
public function deleteDanglingCommitdata(string $name)
|
public function deleteDanglingCommitdata(string $name)
|
||||||
{
|
{
|
||||||
$db = $this->sql_query_assoc_prep("SELECT metadata.hash FROM metadata LEFT JOIN commits WHERE commits.hash IS NULL", []);
|
$hashes = $this->sql_query_assoc_prep("SELECT metadata.hash FROM metadata LEFT JOIN commits ON metadata.hash = commits.hash WHERE commits.hash IS NULL", []);
|
||||||
|
|
||||||
if (count($db) === 0) return;
|
if (count($hashes) === 0) return;
|
||||||
|
|
||||||
$this->logger->proclog("Delete ".count($db)." dangling commits [" . $name . "] from database (no longer linked)");
|
$this->logger->proclog("Deleting ".count($hashes)." dangling commits [" . $name . "] from database (no longer linked)");
|
||||||
|
|
||||||
|
$this->beginTransaction();
|
||||||
|
foreach ($hashes as $hash) {
|
||||||
|
$this->sql_query_assoc_prep("DELETE FROM metadata WHERE hash = :hash", [ [":hash", $hash, PDO::PARAM_STR] ]);
|
||||||
|
}
|
||||||
|
$this->commitTransaction();
|
||||||
|
|
||||||
|
$this->logger->proclog("Succesfully deleted ".count($hashes)." dangling commits");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
www/extern/egg/RemoteSource.php
vendored
2
www/extern/egg/RemoteSource.php
vendored
@ -466,7 +466,6 @@ class GithubConnection extends StandardGitConnection
|
|||||||
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 ]);
|
||||||
$this->logger->proclog("Query commits from: [" . $this->name . "|" . $reponame . "|" . $branchname . "] continuing at {" . substr($startsha, 0, 8) . "}");
|
|
||||||
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +580,6 @@ class GiteaConnection extends StandardGitConnection
|
|||||||
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'=>1024 ]);
|
||||||
$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