diff --git a/module/mr/control.php b/module/mr/control.php index 2a6efb520a..cb9a473cc6 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -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; diff --git a/module/mr/model.php b/module/mr/model.php index 1a89bc1487..d1dd81ec95 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -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"); diff --git a/module/pipeline/config.php b/module/pipeline/config.php index 29bc37b2ea..4c1cdeb9c4 100755 --- a/module/pipeline/config.php +++ b/module/pipeline/config.php @@ -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');