Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit 400e3ddc authored by Rémy Coutable's avatar Rémy Coutable Committed by Oswaldo Ferreira
Browse files

Merge branch 'branch-exists-redis' into 'master'

Use Redis cache for branch existence checks

Closes #40349

See merge request gitlab-org/gitlab-ce!15513

(cherry picked from commit e2e4d18f1c468db8d76aaea1eb1d8442b196244b)

82e9bf29 Use Redis cache for branch existence checks
59fbefbd Add caching test
595631d2 refactor tests
f3156232 apply Rémy's patch
parent dd106868e02e
......@@ -217,11 +217,7 @@ def ref_names
def branch_exists?(branch_name)
return false unless raw_repository
@branch_exists_memo ||= do |hash, key|
hash[key] = raw_repository.branch_exists?(key)
def ref_exists?(ref)
......@@ -1166,6 +1166,31 @@ def expect_to_raise_storage_error
describe '#branch_exists?' do
it 'uses branch_names' do
allow(repository).to receive(:branch_names).and_return(['foobar'])
expect(repository.branch_exists?('foobar')).to eq(true)
expect(repository.branch_exists?('master')).to eq(false)
describe '#branch_names', :use_clean_rails_memory_store_caching do
let(:fake_branch_names) { ['foobar'] }
it 'gets cached across Repository instances' do
allow(repository.raw_repository).to receive(:branch_names).once.and_return(fake_branch_names)
expect(repository.branch_names).to eq(fake_branch_names)
fresh_repository = Project.find(
expect(fresh_repository.object_id).not_to eq(repository.object_id)
expect(fresh_repository.raw_repository).not_to receive(:branch_names)
expect(fresh_repository.branch_names).to eq(fake_branch_names)
describe '#update_autocrlf_option' do
describe 'when autocrlf is not already set to :input' do
before do
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