Class: MergeRequests::RefreshService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/refresh_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(oldrev, newrev, ref) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/merge_requests/refresh_service.rb', line 3

def execute(oldrev, newrev, ref)
  return true unless Gitlab::Git.branch_ref?(ref)

  @oldrev, @newrev = oldrev, newrev
  @branch_name = Gitlab::Git.ref_name(ref)

  find_new_commits
  # Be sure to close outstanding MRs before reloading them to avoid generating an
  # empty diff during a manual merge
  close_merge_requests
  reload_merge_requests
  reset_merge_when_build_succeeds

  # Leave a system note if a branch was deleted/added
  if branch_added? || branch_removed?
    comment_mr_branch_presence_changed
  end

  comment_mr_with_commits
  execute_mr_web_hooks

  true
end