Class: MergeRequests::PostMergeService

Inherits:
BaseService show all
Includes:
RemovesRefs
Defined in:
app/services/merge_requests/post_merge_service.rb

Overview

PostMergeService class

Mark existing merge request as merged and execute all hooks and notifications

Constant Summary collapse

MAX_RETARGET_MERGE_REQUESTS =
4

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods included from RemovesRefs

#cleanup_refs

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_external_hooks, #execute_hooks, #handle_assignees_change, #handle_changes, #handle_reviewers_change, #hook_data, #inspect, #merge_request_activity_counter, #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 BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?

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

#execute(merge_request) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/services/merge_requests/post_merge_service.rb', line 14

def execute(merge_request)
  return if merge_request.merged?

  # Mark the merge request as merged, everything that happens afterwards is
  # executed once
  merge_request.mark_as_merged

  create_event(merge_request)
  todo_service.merge_merge_request(merge_request, current_user)

  merge_request_activity_counter.track_merge_mr_action(user: current_user)

  create_note(merge_request)
  close_issues(merge_request)
  notification_service.merge_mr(merge_request, current_user)
  invalidate_cache_counts(merge_request, users: merge_request.assignees | merge_request.reviewers)
  merge_request.update_project_counter_caches
  remove_all_attention_requests(merge_request)
  delete_non_latest_diffs(merge_request)
  cancel_review_app_jobs!(merge_request)
  cleanup_environments(merge_request)
  cleanup_refs(merge_request)

  execute_hooks(merge_request, 'merge')
end