From 59a1377e5adfade4f83ec2eb325138e859ddbe7a Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Wed, 3 Aug 2022 13:52:51 +0800 Subject: [PATCH] * Adjust codes. --- module/mr/control.php | 2 -- module/repo/model.php | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/module/mr/control.php b/module/mr/control.php index f94de61883..72fac0533e 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -126,12 +126,10 @@ class mr extends control { $gitlabUsers = $this->loadModel('gitlab')->getGitLabListByAccount(); $giteaUsers = $this->gitea->getGiteaListByAccount(); - $gogsUsers = $this->gogs->getGiteaListByAccount(); foreach($hosts as $hostID => $host) { if($host->type == 'gitLab' and isset($gitlabUsers[$hostID])) continue; if($host->type == 'gitea' and isset($giteaUsers[$hostID])) continue; - if($host->type == 'gogs' and isset($gogsUsers[$hostID])) continue; unset($hosts[$hostID]); } diff --git a/module/repo/model.php b/module/repo/model.php index 04e83fa4d0..37f4c0ec3f 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -217,10 +217,10 @@ class repoModel extends model $this->dao->insert(TABLE_REPO)->data($data, $skip = 'serviceToken') ->batchCheck($this->config->repo->create->requiredFields, 'notempty') ->batchCheckIF($data->SCM != 'Gitlab', 'path,client', 'notempty') - ->batchCheckIF(in_array($data->SCM, array('Gitea', 'Gogs')), 'serviceHost,serviceProject', 'notempty') + ->batchCheckIF($isPipelineServer, 'serviceHost,serviceProject', 'notempty') ->batchCheckIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF(in_array($data->SCM, array('Gitea', 'Gogs')), 'serviceProject', 'unique', "`SCM` = '{$data->SCM}'") - ->checkIF(in_array($data->SCM, array('Git', 'Subversion')), 'path', 'unique', "`SCM` = '{$data->SCM}'") + ->checkIF($isPipelineServer, 'serviceProject', 'unique', "`SCM` = '{$data->SCM}'") + ->checkIF(!$isPipelineServer, 'path', 'unique', "`SCM` = '{$data->SCM}'") ->autoCheck() ->exec(); @@ -291,10 +291,10 @@ class repoModel extends model $this->dao->update(TABLE_REPO)->data($data, $skip = 'serviceToken') ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') ->batchCheckIF($data->SCM != 'Gitlab', 'path,client', 'notempty') - ->batchCheckIF(in_array($data->SCM, array('Gitea', 'Gogs')), 'serviceHost,serviceProject', 'notempty') + ->batchCheckIF($isPipelineServer, 'serviceHost,serviceProject', 'notempty') ->batchCheckIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF(in_array($data->SCM, array('Gitea', 'Gogs')), 'serviceProject', 'unique', "`SCM` = '{$data->SCM}' and `id` <> $id") - ->checkIF(in_array($data->SCM, array('Git', 'Subversion')), 'path', 'unique', "`SCM` = '{$data->SCM}' and `id` <> $id") + ->checkIF($isPipelineServer, 'serviceProject', 'unique', "`SCM` = '{$data->SCM}' and `id` <> $id") + ->checkIF(!$isPipelineServer, 'path', 'unique', "`SCM` = '{$data->SCM}' and `id` <> $id") ->autoCheck() ->where('id')->eq($id)->exec();