diff --git a/module/repo/model.php b/module/repo/model.php index b016e4ebdd..e528121511 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -220,7 +220,16 @@ class repoModel extends model ->join('product', ',') ->get(); - if($this->post->SCM == 'Gitlab') $data->path = $this->post->gitlabProject; + if($this->post->SCM == 'Gitlab') + { + $repo = $this->dao->select('id')->from(TABLE_REPO) + ->where('SCM')->eq('Gitlab') + ->andWhere('client')->eq($data->client) + ->andWhere('path')->eq($data->path) + ->fetch(); + if(!empty($repo)) dao::$errors['gitlabProject'] = sprintf($this->lang->error->unique, $this->lang->repo->gitlabProject, $repo->id); + if(dao::isError()) return false; + } $data->acl = empty($data->acl) ? '' : json_encode($data->acl); @@ -239,7 +248,6 @@ class repoModel extends model ->batchCheck($this->config->repo->create->requiredFields, 'notempty') ->checkIF($data->SCM == 'Gitlab', 'gitlabProject', 'notempty') ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF($data->SCM == 'Gitlab', 'path', 'unique', "`SCM` = 'Gitlab' and `client` = {$data->gitlabHost}") ->checkIF($data->SCM == 'Git', 'path', 'unique', "`SCM` = 'Git'") ->checkIF($data->SCM == 'Subversion', 'path', 'unique', "`SCM` = 'Subversion'") ->autoCheck() @@ -309,6 +317,18 @@ class repoModel extends model $data->prefix = ''; } + if($this->post->SCM == 'Gitlab') + { + $repo = $this->dao->select('id')->from(TABLE_REPO) + ->where('SCM')->eq('Gitlab') + ->andWhere('client')->eq($data->client) + ->andWhere('path')->eq($data->path) + ->andWhere('id')->ne($id) + ->fetch(); + if(!empty($repo)) dao::$errors['gitlabProject'] = sprintf($this->lang->error->unique, $this->lang->repo->gitlabProject, $repo->id); + if(dao::isError()) return false; + } + if($data->client != $repo->client and !$this->checkClient()) return false; if(!$this->checkConnection()) return false; @@ -317,7 +337,6 @@ class repoModel extends model ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') ->checkIF($data->SCM == 'Gitlab', 'extra', 'notempty') - ->checkIF($data->SCM == 'Gitlab', 'path', 'unique', "`SCM` = 'Gitlab' and `client` = {$data->gitlabHost} and `id` <> $id") ->checkIF($data->SCM == 'Git', 'path', 'unique', "`SCM` = 'Git' and `id` <> $id") ->checkIF($data->SCM == 'Subversion', 'path', 'unique', "`SCM` = 'Subversion' and `id` <> $id") ->autoCheck() diff --git a/module/repo/view/create.html.php b/module/repo/view/create.html.php index 46466bb566..0c7b890b18 100644 --- a/module/repo/view/create.html.php +++ b/module/repo/view/create.html.php @@ -34,11 +34,11 @@ repo->gitlabHost;?> - repo->placeholder->gitlabHost}'");?> + repo->placeholder->gitlabHost}'");?> repo->gitlabProject;?> - + repo->name; ?> diff --git a/module/repo/view/edit.html.php b/module/repo/view/edit.html.php index d7dfd84332..efa6f3c76e 100644 --- a/module/repo/view/edit.html.php +++ b/module/repo/view/edit.html.php @@ -38,11 +38,11 @@ repo->gitlabHost;?> - gitlab) ? $repo->gitlab : '', "class='form-control chosen' placeholder='{$lang->repo->placeholder->gitlabHost}'");?> + gitlab) ? $repo->gitlab : '', "class='form-control chosen' placeholder='{$lang->repo->placeholder->gitlabHost}'");?> repo->gitlabProject;?> - project) ? $repo->project : '', "class='form-control chosen'");?> + project) ? $repo->project : '', "class='form-control chosen'");?> repo->name; ?>