diff options
Diffstat (limited to 'app/services/auto_merge')
-rw-r--r-- | app/services/auto_merge/merge_when_pipeline_succeeds_service.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/services/auto_merge/merge_when_pipeline_succeeds_service.rb b/app/services/auto_merge/merge_when_pipeline_succeeds_service.rb index 2bbb8f925a4..cb8e531f0e1 100644 --- a/app/services/auto_merge/merge_when_pipeline_succeeds_service.rb +++ b/app/services/auto_merge/merge_when_pipeline_succeeds_service.rb @@ -4,9 +4,7 @@ module AutoMerge class MergeWhenPipelineSucceedsService < AutoMerge::BaseService def execute(merge_request) super do - if merge_request.saved_change_to_auto_merge_enabled? - SystemNoteService.merge_when_pipeline_succeeds(merge_request, project, current_user, merge_request.actual_head_pipeline.sha) - end + add_system_note(merge_request) end end @@ -36,12 +34,20 @@ module AutoMerge def available_for?(merge_request) super do - merge_request.actual_head_pipeline&.active? + check_availability(merge_request) end end private + def add_system_note(merge_request) + SystemNoteService.merge_when_pipeline_succeeds(merge_request, project, current_user, merge_request.actual_head_pipeline.sha) if merge_request.saved_change_to_auto_merge_enabled? + end + + def check_availability(merge_request) + merge_request.actual_head_pipeline&.active? + end + def notify(merge_request) notification_service.async.merge_when_pipeline_succeeds(merge_request, current_user) if merge_request.saved_change_to_auto_merge_enabled? end |