Class: MergeRequests::MergeOrchestrationService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/merge_requests/merge_orchestration_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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

#can_merge?(merge_request) ⇒ Boolean

Returns:

  • (Boolean)

17
18
19
# File 'app/services/merge_requests/merge_orchestration_service.rb', line 17

def can_merge?(merge_request)
  can_merge_automatically?(merge_request) || can_merge_immediately?(merge_request)
end

#execute(merge_request) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'app/services/merge_requests/merge_orchestration_service.rb', line 5

def execute(merge_request)
  return unless can_merge?(merge_request)

  merge_request.update(merge_error: nil)

  if can_merge_automatically?(merge_request)
    auto_merge_service.execute(merge_request)
  else
    merge_request.merge_async(current_user.id, params)
  end
end

#preferred_auto_merge_strategy(merge_request) ⇒ Object


21
22
23
# File 'app/services/merge_requests/merge_orchestration_service.rb', line 21

def preferred_auto_merge_strategy(merge_request)
  auto_merge_service.preferred_strategy(merge_request)
end