Class: MergeRequests::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/update_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

#close_serviceObject


62
63
64
# File 'app/services/merge_requests/update_service.rb', line 62

def close_service
  MergeRequests::CloseService
end

#execute(merge_request) ⇒ Object


7
8
9
10
11
12
13
14
15
# File 'app/services/merge_requests/update_service.rb', line 7

def execute(merge_request)
  # We don't allow change of source/target projects and source branch
  # after merge request was created
  params.except!(:source_project_id)
  params.except!(:target_project_id)
  params.except!(:source_branch)

  update(merge_request)
end

#handle_changes(merge_request, old_labels: []) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/services/merge_requests/update_service.rb', line 17

def handle_changes(merge_request, old_labels: [])
  if has_changes?(merge_request, old_labels: old_labels)
    todo_service.mark_pending_todos_as_done(merge_request, current_user)
  end

  if merge_request.previous_changes.include?('title') ||
     merge_request.previous_changes.include?('description')
    todo_service.update_merge_request(merge_request, current_user)
  end

  if merge_request.previous_changes.include?('target_branch')
    create_branch_change_note(merge_request, 'target',
                              merge_request.previous_changes['target_branch'].first,
                              merge_request.target_branch)
  end

  if merge_request.previous_changes.include?('milestone_id')
    create_milestone_note(merge_request)
  end

  if merge_request.previous_changes.include?('assignee_id')
    create_assignee_note(merge_request)
    notification_service.reassigned_merge_request(merge_request, current_user)
    todo_service.reassigned_merge_request(merge_request, current_user)
  end

  if merge_request.previous_changes.include?('target_branch') ||
      merge_request.previous_changes.include?('source_branch')
    merge_request.mark_as_unchecked
  end

  added_labels = merge_request.labels - old_labels
  if added_labels.present?
    notification_service.relabeled_merge_request(
      merge_request,
      added_labels,
      current_user
    )
  end
end

#reopen_serviceObject


58
59
60
# File 'app/services/merge_requests/update_service.rb', line 58

def reopen_service
  MergeRequests::ReopenService
end