Commit 8cdb3477 authored by Ahmad Sherif's avatar Ahmad Sherif

Remove allow_n_plus_1 from Git::Repository#branches_filter

parent 5edd94ae
...@@ -1614,17 +1614,14 @@ module Gitlab ...@@ -1614,17 +1614,14 @@ module Gitlab
# Gitaly note: JV: Trying to get rid of the 'filter' option so we can implement this with 'git'. # Gitaly note: JV: Trying to get rid of the 'filter' option so we can implement this with 'git'.
def branches_filter(filter: nil, sort_by: nil) def branches_filter(filter: nil, sort_by: nil)
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37464 branches = rugged.branches.each(filter).map do |rugged_ref|
branches = Gitlab::GitalyClient.allow_n_plus_1_calls do begin
rugged.branches.each(filter).map do |rugged_ref| target_commit = Gitlab::Git::Commit.find(self, rugged_ref.target)
begin Gitlab::Git::Branch.new(self, rugged_ref.name, rugged_ref.target, target_commit)
target_commit = Gitlab::Git::Commit.find(self, rugged_ref.target) rescue Rugged::ReferenceError
Gitlab::Git::Branch.new(self, rugged_ref.name, rugged_ref.target, target_commit) # Omit invalid branch
rescue Rugged::ReferenceError end
# Omit invalid branch end.compact
end
end.compact
end
sort_branches(branches, sort_by) sort_branches(branches, sort_by)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment