Commit d5e86f1a authored by Sean Carroll's avatar Sean Carroll

Simplify execute method

parent dc22f476
......@@ -14,7 +14,17 @@ module MergeTrains
@merge_request = merge_request
validate!
pipeline_created = create_or_replace_pipeline
merge! if should_merge?
success(pipeline_created: pipeline_created.present?)
rescue ProcessError => e
drop(e)
end
private
def create_or_replace_pipeline
if should_create_pipeline?
previous_pipeline = pipeline_for_merge_train
pipeline_created = create_pipeline!
......@@ -22,16 +32,9 @@ module MergeTrains
previous_pipeline.auto_cancel_running(pipeline_created)
end
end
merge! if should_merge?
success(pipeline_created: pipeline_created.present?)
rescue ProcessError => e
drop(e)
pipeline_created
end
private
def validate!
unless project.merge_trains_enabled?
raise ProcessError, 'project disabled merge trains'
......
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