Merge branch 'cyy_repo_bug' into 'master'

* Modify commit link object error.

See merge request easycorp/zentaopms!6952
This commit is contained in:
王怡栋
2023-02-15 01:13:05 +00:00
2 changed files with 30 additions and 15 deletions
+1 -13
View File
@@ -598,19 +598,7 @@ class repo extends control
}
/* Refresh repo. */
if($refresh)
{
/* Update code commit history. */
$commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repo->id));
if(in_array($repo->SCM, $this->config->repo->gitTypeList))
{
$branch = $this->cookie->repoBranch;
$this->loadModel('git')->updateCommit($repo, $commentGroup, false);
$_COOKIE['repoBranch'] = $branch;
}
if($repo->SCM == 'Subversion') $this->loadModel('svn')->updateCommit($repo, $commentGroup, false);
}
if($refresh) $this->repo->updateCommit($repoID);
/* Get files info. */
$infos = $this->repo->getFileCommits($repo, $branchID, $path);
+29 -2
View File
@@ -333,8 +333,13 @@ class repoModel extends model
if($type == 'task') $links = $this->post->tasks;
$revisionInfo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->andWhere('revision')->eq($revision)->fetch();
$revisionID = $revisionInfo->id;
$committer = $this->dao->select('account')->from(TABLE_USER)->where('commiter')->eq($revisionInfo->committer)->fetch('account');
if(empty($revisionInfo)) $this->updateCommit($repoID);
$revisionInfo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->andWhere('revision')->eq($revision)->fetch();
if(empty($revisionInfo)) return false;
$revisionID = $revisionInfo->id;
$committer = $this->dao->select('account')->from(TABLE_USER)->where('commiter')->eq($revisionInfo->committer)->fetch('account');
if(empty($committer)) $committer = $revisionInfo->committer;
foreach($links as $linkID)
{
@@ -2769,4 +2774,26 @@ class repoModel extends model
$linkedProjects = $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($projectIDList)->fetchPairs('id', 'name');
return $accessProjects + $linkedProjects; // Merge projects can be accessed and exists.
}
/**
* Update commit history.
*
* @param int $repoID
* @access public
* @return void
*/
public function updateCommit($repoID)
{
$repo = $this->getRepoByID($repoID);
/* Update code commit history. */
$commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repoID));
if(in_array($repo->SCM, $this->config->repo->gitTypeList))
{
$branch = $this->cookie->repoBranch;
$this->loadModel('git')->updateCommit($repo, $commentGroup, false);
$_COOKIE['repoBranch'] = $branch;
}
if($repo->SCM == 'Subversion') $this->loadModel('svn')->updateCommit($repo, $commentGroup, false);
}
}