Class: MergeRequests::GetUrlsService

Inherits:
BaseProjectService show all
Defined in:
app/services/merge_requests/get_urls_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

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

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?

Constructor Details

This class inherits a constructor from BaseProjectService

Instance Method Details

#execute(changes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/merge_requests/get_urls_service.rb', line 5

def execute(changes)
  return [] unless project&.printing_merge_request_link_enabled

  branches = get_branches(changes)
  merge_requests_map = opened_merge_requests_from_source_branches(branches)
  branches.map do |branch|
    existing_merge_request = merge_requests_map[branch]
    if existing_merge_request
      url_for_existing_merge_request(existing_merge_request)
    else
      url_for_new_merge_request(branch)
    end
  end
end