Class: MergeRequests::CreateService

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

Direct Known Subclasses

CreateFromIssueService

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_hooks, #hook_data, #inspect, #source_project, #target_project

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from AssignsMergeParams

#assign_allowed_merge_params, included

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?

Instance Method Details

#after_create(issuable) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/merge_requests/create_service.rb', line 16

def after_create(issuable)
  # Add new items to MergeRequests::AfterCreateService if they can
  # be performed in Sidekiq
  NewMergeRequestWorker.perform_async(issuable.id, current_user.id)

  todo_service.new_merge_request(issuable, current_user)
  issuable.cache_merge_request_closes_issues!(current_user)

  Gitlab::UsageDataCounters::MergeRequestCounter.count(:create)
  link_lfs_objects(issuable)

  super
end

#create(merge_request) ⇒ Object

expose issuable create method so it can be called from email handler CreateMergeRequestHandler


32
33
34
# File 'app/services/merge_requests/create_service.rb', line 32

def create(merge_request)
  super
end

#executeObject


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

def execute
  set_projects!

  merge_request = MergeRequest.new
  merge_request.target_project = @project
  merge_request.source_project = @source_project
  merge_request.source_branch = params[:source_branch]

  create(merge_request)
end