* 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
+13
View File
@@ -328,6 +328,19 @@ class GitRepo
return $info;
}
/**
* Exec git cmd.
*
* @param string $cmd
* @access public
* @return array
*/
public function exec($cmd)
{
chdir($this->root);
return execCmd(escapeCmd("$this->client $cmd"), 'array');
}
/**
* Parse diff.
*
+12
View File
@@ -141,6 +141,18 @@ class scm
return $this->engine->info($entry, $revision);
}
/**
* Exec scm cmd.
*
* @param string $cmd
* @access public
* @return array
*/
public function exec($cmd)
{
return $this->engine->exec($cmd);
}
/**
* Get commit count
*
+13
View File
@@ -403,6 +403,19 @@ class Subversion
return $info;
}
/**
* Exec svn cmd.
*
* @param string $cmd
* @access public
* @return array
*/
public function exec($cmd)
{
$cmd = $this->replaceAuth(escapeCmd($this->buildCMD('', $cmd, '')));
return execCmd($cmd, 'array');
}
/**
* Parse diff.
*
+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;