Commit 13d65ddc authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'cache-ambiguous-refs-properly' into 'master'

Cache Repository#has_ambiguous_refs? properly

See merge request gitlab-org/gitlab!39707
parents 99ed8fec 8ca55c37
......@@ -220,6 +220,7 @@ class Repository
prefix_regex.match?(ref)
end
end
cache_method :has_ambiguous_refs?
def expand_ref(ref)
if tag_exists?(ref)
......@@ -311,12 +312,12 @@ class Repository
end
def expire_tags_cache
expire_method_caches(%i(tag_names tag_count))
expire_method_caches(%i(tag_names tag_count has_ambiguous_refs?))
@tags = nil
end
def expire_branches_cache
expire_method_caches(%i(branch_names merged_branch_names branch_count has_visible_content?))
expire_method_caches(%i(branch_names merged_branch_names branch_count has_visible_content? has_ambiguous_refs?))
@local_branches = nil
@branch_exists_memo = nil
end
......
......@@ -2103,7 +2103,7 @@ RSpec.describe Repository do
describe '#expire_branches_cache' do
it 'expires the cache' do
expect(repository).to receive(:expire_method_caches)
.with(%i(branch_names merged_branch_names branch_count has_visible_content?))
.with(%i(branch_names merged_branch_names branch_count has_visible_content? has_ambiguous_refs?))
.and_call_original
repository.expire_branches_cache
......@@ -2113,7 +2113,7 @@ RSpec.describe Repository do
describe '#expire_tags_cache' do
it 'expires the cache' do
expect(repository).to receive(:expire_method_caches)
.with(%i(tag_names tag_count))
.with(%i(tag_names tag_count has_ambiguous_refs?))
.and_call_original
repository.expire_tags_cache
......
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