* code for task #7548.

This commit is contained in:
z
2020-07-24 21:45:48 +08:00
parent 9b835f13fd
commit f4987f4a04
4 changed files with 43 additions and 30 deletions
+5 -30
View File
@@ -409,39 +409,14 @@ class repo extends control
{
if($repo->SCM == 'Git')
{
$branch = $this->dao->select('*')->from(TABLE_REPOBRANCH)->where('revision')->eq($history->id)->fetch('branch');
$prevHistories = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.id')->le($history->id)
->andWhere('t1.repo')->eq($repoID)
->andWhere('t2.branch')->eq($branch)
->orderBy('t1.time_desc')
->limit(2)
->fetchAll();
$currentHistory = array_shift($prevHistories);
if($history->id != $currentHistory->id)
{
$prevHistories = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.id')->ge($history->id)
->andWhere('t1.repo')->eq($repoID)
->andWhere('t2.branch')->eq($branch)
->orderBy('t1.time_desc')
->limit(2)
->fetchAll();
array_shift($prevHistories);
}
$prevHistory = array_pop($prevHistories);
if($prevHistory) $oldRevision = $prevHistory->revision;
$thisAndPrevRevisions = $this->scm->exec("rev-list -n 2 {$history->revision} --");
array_shift($thisAndPrevRevisions);
if($thisAndPrevRevisions) $oldRevision = array_shift($thisAndPrevRevisions);
}
else
{
$oldRevision = $this->dao->select('*')->from(TABLE_REPOHISTORY)
->where('revision')->lt($history->revision)
->andWhere('repo')->eq($repoID)
->orderBy('revision_desc')
->limit(1)
->fetch('revision');
$oldRevision = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('revision')->lt($history->revision)->andWhere('repo')->eq($repoID)->orderBy('revision_desc')->limit(1)->fetch('revision');
}
$log[0]->commit = $history->commit;