debian-mirror-gitlab/app/services/merge_requests/pushed_branches_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
905 B
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module MergeRequests
class PushedBranchesService < MergeRequests::BaseService
include ::Gitlab::Utils::StrongMemoize
# Skip moving this logic into models since it's too specific
# rubocop: disable CodeReuse/ActiveRecord
def execute
return [] if branch_names.blank?
2020-10-24 23:57:45 +05:30
source_branches = project.source_of_merge_requests.open_and_closed
2020-04-22 19:07:51 +05:30
.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
# rubocop: enable CodeReuse/ActiveRecord
private
def branch_names
strong_memoize(:branch_names) do
params[:changes].map do |change|
Gitlab::Git.branch_name(change[:ref])
end.compact
end
end
end
end