fixed reposyncer 分支组合已配置,不能重复

This commit is contained in:
“xxq250” 2022-08-04 16:50:01 +08:00
parent 5c361207f5
commit 4fb2003f64
1 changed files with 7 additions and 0 deletions

View File

@ -48,6 +48,13 @@ class ObRepositorySyncsController < ApplicationController
end
def create_jobs
tip_exception "必须配置一个分支" if params[:github_branch].blank? && params[:gitee_branch].blank? && params[:gitlink_branch].blank?
ob_jobs = ObRepositorySyncJob.where(ob_repository_sync_id: @ob_repository_sync.id)
ob_jobs.where(job_type: params[:job_type]) if params[:job_type].present?
ob_jobs.where(github_branch: params[:github_branch]) if params[:github_branch].present?
ob_jobs.where(gitee_branch: params[:gitee_branch]) if params[:gitee_branch].present?
ob_jobs.where(gitlink_branch: params[:gitlink_branch]) if params[:gitlink_branch].present?
tip_exception "该分支组合已配置,不能重复!" if ob_jobs.count > 0
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
res = service.create_projects_jobs(params)
tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"