Class: AutoMerge::MergeWhenPipelineSucceedsService

Inherits:
BaseService show all
Defined in:
app/services/auto_merge/merge_when_pipeline_succeeds_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#can_add_to_merge_train?, can_add_to_merge_train?, #update

Methods included from MergeRequests::AssignsMergeParams

#assign_allowed_merge_params, included

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#abort(merge_request, reason) ⇒ Object


26
27
28
29
30
# File 'app/services/auto_merge/merge_when_pipeline_succeeds_service.rb', line 26

def abort(merge_request, reason)
  super do
    SystemNoteService.abort_merge_when_pipeline_succeeds(merge_request, project, current_user, reason)
  end
end

#available_for?(merge_request) ⇒ Boolean

Returns:

  • (Boolean)

32
33
34
35
36
# File 'app/services/auto_merge/merge_when_pipeline_succeeds_service.rb', line 32

def available_for?(merge_request)
  super do
    merge_request.actual_head_pipeline&.active?
  end
end

#cancel(merge_request) ⇒ Object


20
21
22
23
24
# File 'app/services/auto_merge/merge_when_pipeline_succeeds_service.rb', line 20

def cancel(merge_request)
  super do
    SystemNoteService.cancel_merge_when_pipeline_succeeds(merge_request, project, current_user)
  end
end

#execute(merge_request) ⇒ Object


5
6
7
8
9
10
11
# File 'app/services/auto_merge/merge_when_pipeline_succeeds_service.rb', line 5

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
  end
end

#process(merge_request) ⇒ Object


13
14
15
16
17
18
# File 'app/services/auto_merge/merge_when_pipeline_succeeds_service.rb', line 13

def process(merge_request)
  return unless merge_request.actual_head_pipeline_success?
  return unless merge_request.mergeable?

  merge_request.merge_async(merge_request.merge_user_id, merge_request.merge_params)
end