Class: MergeRequests::BaseService

Inherits:
IssuableBaseService show all
Defined in:
app/services/merge_requests/base_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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

#create_note(merge_request) ⇒ Object


4
5
6
# File 'app/services/merge_requests/base_service.rb', line 4

def create_note(merge_request)
  SystemNoteService.change_status(merge_request, merge_request.target_project, current_user, merge_request.state, nil)
end

#create_title_change_note(issuable, old_title) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/merge_requests/base_service.rb', line 8

def create_title_change_note(issuable, old_title)
  removed_wip = old_title =~ MergeRequest::WIP_REGEX && !issuable.work_in_progress?
  added_wip = old_title !~ MergeRequest::WIP_REGEX && issuable.work_in_progress?

  if removed_wip
    SystemNoteService.remove_merge_request_wip(issuable, issuable.project, current_user)
  elsif added_wip
    SystemNoteService.add_merge_request_wip(issuable, issuable.project, current_user)
  else
    super
  end
end

#execute_hooks(merge_request, action = 'open') ⇒ Object


28
29
30
31
32
33
34
# File 'app/services/merge_requests/base_service.rb', line 28

def execute_hooks(merge_request, action = 'open')
  if merge_request.project
    merge_data = hook_data(merge_request, action)
    merge_request.project.execute_hooks(merge_data, :merge_request_hooks)
    merge_request.project.execute_services(merge_data, :merge_request_hooks)
  end
end

#hook_data(merge_request, action) ⇒ Object


21
22
23
24
25
26
# File 'app/services/merge_requests/base_service.rb', line 21

def hook_data(merge_request, action)
  hook_data = merge_request.to_hook_data(current_user)
  hook_data[:object_attributes][:url] = Gitlab::UrlBuilder.build(merge_request)
  hook_data[:object_attributes][:action] = action
  hook_data
end