Class: MergeRequests::CloseService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/close_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#create_note, #create_title_change_note, #execute_hooks, #hook_data

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(merge_request, commit = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/merge_requests/close_service.rb', line 3

def execute(merge_request, commit = nil)
  # If we close MergeRequest we want to ignore validation
  # so we can close broken one (Ex. fork project removed)
  merge_request.allow_broken = true

  if merge_request.close
    event_service.close_mr(merge_request, current_user)
    create_note(merge_request)
    notification_service.close_mr(merge_request, current_user)
    todo_service.close_merge_request(merge_request, current_user)
    execute_hooks(merge_request, 'close')
  end

  merge_request
end