Update extgitgraph to f4853a2f
This commit is contained in:
parent
990e803192
commit
bd5d13003b
25
www/extern/egg/EGGDatabase.php
vendored
25
www/extern/egg/EGGDatabase.php
vendored
@ -461,4 +461,29 @@ class EGGDatabase
|
||||
foreach ($rows as $row) $r []= $row['d'];
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Commit[]
|
||||
*/
|
||||
public function getCommits(Branch $branch): array
|
||||
{
|
||||
$rows = $this->sql_query_assoc("SELECT metadata.*, commits.id AS commitid FROM commits LEFT JOIN metadata WHERE commits.branch_id = :bid", [[":bid", $branch->ID, PDO::PARAM_INT]]);
|
||||
$r = [];
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$c = new Commit();
|
||||
$c->ID = $row['commitid'];
|
||||
$c->Branch = $branch;
|
||||
$c->Hash = $row['hash'];
|
||||
$c->AuthorName = $row['author_name'];
|
||||
$c->AuthorEmail = $row['author_email'];
|
||||
$c->CommitterName = $row['committer_name'];
|
||||
$c->CommitterEmail = $row['committer_email'];
|
||||
$c->Message = $row['message'];
|
||||
$c->Date = $row['date'];
|
||||
$c->Parents = $row['parent_commits'];
|
||||
$r []= $c;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
}
|
13
www/extern/egg/RemoteSource.php
vendored
13
www/extern/egg/RemoteSource.php
vendored
@ -233,9 +233,10 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
if ($branch->HeadFromAPI === null) return [];
|
||||
|
||||
$target = $branch->Head;
|
||||
$targetFound = false;
|
||||
|
||||
$next_sha = [ $branch->HeadFromAPI ];
|
||||
$visited = [ ];
|
||||
$visited = array_map(function(Commit $m):string{return $m->Hash;}, $db->getCommits($branch));
|
||||
|
||||
$json = $this->queryCommits($repo->Name, $branch->Name, $next_sha[0]);
|
||||
|
||||
@ -260,19 +261,25 @@ abstract class StandardGitConnection implements IRemoteSource
|
||||
if (in_array($sha, $visited)) continue;
|
||||
$visited []= $sha;
|
||||
|
||||
if ($sha === $target && count($next_sha) === 0)
|
||||
if ($sha === $target) $targetFound = true;
|
||||
|
||||
if ($targetFound && count($next_sha) === 0)
|
||||
{
|
||||
if (count($newcommits) === 0)
|
||||
{
|
||||
$this->logger->proclog("Found no new commits for: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] (HEAD at {" . substr($branch->HeadFromAPI, 0, 8) . "})");
|
||||
return [];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->logger->proclog("Added " . count($newcommits) . " new commits for: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] (HEAD moved from {" . substr($branch->Head, 0, 8) . "} to {" . substr($branch->HeadFromAPI, 0, 8) . "})");
|
||||
|
||||
$db->insertNewCommits($this->name, $repo, $branch, $newcommits);
|
||||
$db->setBranchHead($branch, $branch->HeadFromAPI);
|
||||
|
||||
return $newcommits;
|
||||
}
|
||||
}
|
||||
|
||||
$commit = new Commit();
|
||||
$commit->Branch = $branch;
|
||||
@ -299,7 +306,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)."})");
|
||||
$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)) . "] )");
|
||||
|
||||
$db->deleteAllCommits($branch);
|
||||
|
||||
|
15
www/extern/egg/db_init.sql
vendored
15
www/extern/egg/db_init.sql
vendored
@ -56,4 +56,17 @@ CREATE VIEW alldata AS
|
||||
FROM commits
|
||||
LEFT JOIN metadata ON commits.hash = metadata.hash
|
||||
LEFT JOIN branches ON commits.branch_id = branches.id
|
||||
LEFT JOIN repositories ON branches.repo_id = repositories.id
|
||||
LEFT JOIN repositories ON branches.repo_id = repositories.id;
|
||||
|
||||
/*----SPLIT----*/
|
||||
|
||||
CREATE VIEW allbranches AS
|
||||
SELECT
|
||||
repositories.source, repositories.name AS repository,
|
||||
branches.name AS branch,
|
||||
repositories.url,
|
||||
repositories.last_update, repositories.last_change,
|
||||
(SELECT COUNT(*) FROM commits WHERE branch_id = branches.id) AS commit_count
|
||||
FROM branches
|
||||
LEFT JOIN repositories ON branches.repo_id = repositories.id;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user