- [task#120961,0.5h] delete unused codes for mr.

This commit is contained in:
caoyanyi
2024-06-19 16:32:25 +08:00
committed by 田淑杰
parent 4ff003b687
commit 98ceb03d7f
3 changed files with 6 additions and 52 deletions
+4 -19
View File
@@ -210,14 +210,7 @@ class mr extends control
}
if(in_array($repo->SCM, $this->config->repo->notSyncSCM)) $repo->serviceProject = (int)$repo->serviceProject;
if($repo->SCM == 'GitFox')
{
$project = $this->loadModel('gitfox')->apiGetSingleRepo($repo->gitService, $repo->serviceProject);
}
else
{
$project = $this->loadModel(strtolower($repo->SCM))->apiGetSingleProject($repo->gitService, $repo->serviceProject, false);
}
$project = $this->loadModel(strtolower($repo->SCM))->apiGetSingleProject($repo->gitService, $repo->serviceProject, false);
$jobPairs = array();
$jobs = $this->loadModel('job')->getListByRepoID($repoID);
@@ -319,14 +312,13 @@ class mr extends control
}
$host = $this->loadModel('pipeline')->getByID($MR->hostID);
if(in_array($host->type, array('gitlab', 'gitfox')))
if(in_array($host->type, $this->config->pipeline->formatTypeService))
{
$MR->sourceProject = (int)$MR->sourceProject;
$MR->targetProject = (int)$MR->targetProject;
}
$projectMethod = $host->type == 'gitfox' ? 'apiGetSingleRepo' : 'apiGetSingleProject';
$sourceProject = $this->loadModel($host->type)->$projectMethod($MR->hostID, $MR->sourceProject);
$sourceProject = $this->loadModel($host->type)->apiGetSingleProject($MR->hostID, $MR->sourceProject);
$compile = $this->loadModel('compile')->getByID($MR->compileID);
$this->view->title = $this->lang->mr->view;
@@ -807,14 +799,7 @@ class mr extends control
foreach($commitLogs as $commitLog)
{
$commitLog->repoID = $MR->repoID;
if(strtolower($repo->SCM) == 'gitfox')
{
$commitLog->id = $commitLog->sha;
$commitLog->committed_date = date('Y-m-d H:i:s', strtotime($commitLog->author->when));
$commitLog->committer_name = $commitLog->author->identity->name;
$commitLog->committer_email = $commitLog->author->identity->email;
}
elseif(in_array(strtolower($repo->SCM), array('gitea', 'gogs')))
if(in_array(strtolower($repo->SCM), array('gitea', 'gogs')))
{
$commitLog->id = $commitLog->sha;
$commitLog->committed_date = $commitLog->author->committer->date;
-33
View File
@@ -158,35 +158,6 @@ class mrModel extends model
return $allProjectPairs;
}
/**
* 获取GitFox服务器的项目.
* Get gitfox projects.
*
* @param int $hostID
* @param array $projectIdList
* @access public
* @return array
*/
public function getGitFoxProjects(int $hostID = 0, array $projectIdList = array()): array
{
$gitfoxUsers = $this->loadModel('pipeline')->getProviderPairsByAccount('gitfox');
if(!$this->app->user->admin && !isset($gitfoxUsers[$hostID])) return array();
$projectPairs = array();
$projects = $this->loadModel('gitfox')->apiGetRepos($hostID);
foreach($projects as $project)
{
if($projectIdList && !in_array($project->id, $projectIdList)) continue;
$project->full_name = $project->path;
$projectPairs[$hostID][$project->id] = $project;
$project->isDeveloper = true;
}
return $projectPairs;
}
/**
* 创建合并请求。
* Create MR function.
@@ -565,10 +536,6 @@ class mrModel extends model
{
$url = sprintf($apiRoot, "/projects/$projectID/merge_requests/$MRID/commits");
}
elseif($host->type == 'gitfox')
{
$url = sprintf($apiRoot->url, "/repos/$projectID/pullreq/$MRID/commits");
}
else
{
$url = sprintf($apiRoot, "/repos/$projectID/pulls/$MRID/commits");
+2
View File
@@ -3,3 +3,5 @@ $config->pipeline->create = new stdclass();
$config->pipeline->edit = new stdclass();
$config->pipeline->create->requiredFields = 'name,url,type';
$config->pipeline->edit->requiredFields = 'name,url,type';
$config->pipeline->formatTypeService = array('gitlab');