Class: MergeRequests::PushedBranchesService

Inherits:
BaseService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/merge_requests/pushed_branches_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

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

#executeObject

Skip moving this logic into models since it's too specific rubocop: disable CodeReuse/ActiveRecord


9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/merge_requests/pushed_branches_service.rb', line 9

def execute
  return [] if branch_names.blank?

  source_branches = project.source_of_merge_requests.open_and_closed
    .from_source_branches(branch_names).pluck(:source_branch)

  target_branches = project.merge_requests.opened
    .by_target_branch(branch_names).distinct.pluck(:target_branch)

  source_branches.concat(target_branches).to_set
end