Commit d5e86f1a authored by Sean Carroll's avatar Sean Carroll

Simplify execute method

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