Commit 59e73d35 authored by Marc Shaw's avatar Marc Shaw

Memoize the code owners file after loading

MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/60980
parent 4b53a281
......@@ -62,11 +62,7 @@ module Gitlab
end
def code_owners_file
if RequestStore.active?
RequestStore.fetch("project-#{@project.id}:code-owners:#{@ref}") do
load_code_owners_file
end
else
@code_owners_file ||= Gitlab::SafeRequestStore.fetch("project-#{@project.id}:code-owners:#{@ref}") do
load_code_owners_file
end
end
......
......@@ -43,6 +43,12 @@ RSpec.describe Gitlab::CodeOwners::Loader do
expect(loader.entries).to contain_exactly(expected_entry)
end
it 'only calls out to the repository once' do
expect(project.repository).to receive(:code_owners_blob).once
2.times { loader.entries }
end
it 'loads all users that are members of the project into the entry' do
expect(first_entry.users).to contain_exactly(owner_1, email_owner, documentation_owner)
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