From 2c648b7941d6d17aa60d15cfe6aaebeaf48eff8f Mon Sep 17 00:00:00 2001 From: victor <121183489011@qq.com> Date: Wed, 27 Jan 2021 16:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/pipelines_controller.rb | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/controllers/ci/pipelines_controller.rb b/app/controllers/ci/pipelines_controller.rb index 50417ce80..4dda451f3 100644 --- a/app/controllers/ci/pipelines_controller.rb +++ b/app/controllers/ci/pipelines_controller.rb @@ -70,17 +70,20 @@ class Ci::PipelinesController < Ci::BaseController # 在drone数据库repo表新增一条repo记录 def create_ci_repo(pipeline) - create_params = { - repo_user_id: @ci_user.user_id, - repo_namespace: @project.owner.login, - repo_name: @project.identifier, - repo_slug: "#{@project.owner.login}/#{@project.identifier}-" + pipeline.id.to_s, - repo_clone_url: @project.repository.url, - repo_branch: pipeline.branch, - repo_config: pipeline.file_name - } - repo = Ci::Repo.create_repo(create_params) - repo + if pipeline.branch != 'master' + create_params = { + repo_user_id: @ci_user.user_id, + repo_namespace: @project.owner.login, + repo_name: @project.identifier, + repo_slug: "#{@project.owner.login}/#{@project.identifier}-" + pipeline.id.to_s, + repo_clone_url: @project.repository.url, + repo_branch: pipeline.branch, + repo_config: pipeline.file_name + } + repo = Ci::Repo.create_repo(create_params) + repo + end + nil end def get_pipeline_file_sha(file_name, branch) @@ -88,9 +91,7 @@ class Ci::PipelinesController < Ci::BaseController interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: branch || 'master') if interactor.success? file = interactor.result - return file['sha'] - else - return nil + file['sha'] end end