Commit 353dd40c authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'refactor-mr-create-pipeline-service' into 'master'

Refactor Merge Requests Create Pipeline Service

See merge request gitlab-org/gitlab!25846
parents 8db7ceea a89d93ec
......@@ -9,15 +9,10 @@ module MergeRequests
end
def create_detached_merge_request_pipeline(merge_request)
if can_use_merge_request_ref?(merge_request)
Ci::CreatePipelineService.new(merge_request.source_project, current_user,
ref: merge_request.ref_path)
.execute(:merge_request_event, merge_request: merge_request)
else
Ci::CreatePipelineService.new(merge_request.source_project, current_user,
ref: merge_request.source_branch)
.execute(:merge_request_event, merge_request: merge_request)
end
Ci::CreatePipelineService.new(merge_request.source_project,
current_user,
ref: pipeline_ref_for_detached_merge_request_pipeline(merge_request))
.execute(:merge_request_event, merge_request: merge_request)
end
def can_create_pipeline_for?(merge_request)
......@@ -33,6 +28,16 @@ module MergeRequests
def allow_duplicate
params[:allow_duplicate]
end
private
def pipeline_ref_for_detached_merge_request_pipeline(merge_request)
if can_use_merge_request_ref?(merge_request)
merge_request.ref_path
else
merge_request.source_branch
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment