Commit 1b2a94c1 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'zj-repository-exist-mandatory' into 'master'

Repository#exists? can only be queried with Gitaly

Closes gitaly#314

See merge request gitlab-org/gitlab-ce!18567
parents 3a4c2f05 5cd57cf2
---
title: Repository#exists? is always executed through Gitaly
merge_request:
author:
type: performance
...@@ -142,15 +142,7 @@ module Gitlab ...@@ -142,15 +142,7 @@ module Gitlab
end end
def exists? def exists?
Gitlab::GitalyClient.migrate(:repository_exists, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled| gitaly_repository_client.exists?
if enabled
gitaly_repository_client.exists?
else
circuit_breaker.perform do
File.exist?(File.join(path, 'refs'))
end
end
end
end end
# Returns an Array of branch names # Returns an Array of branch names
......
...@@ -1224,15 +1224,15 @@ describe Repository do ...@@ -1224,15 +1224,15 @@ describe Repository do
end end
end end
shared_examples 'repo exists check' do describe '#exists?' do
it 'returns true when a repository exists' do it 'returns true when a repository exists' do
expect(repository.exists?).to eq(true) expect(repository.exists?).to be(true)
end end
it 'returns false if no full path can be constructed' do it 'returns false if no full path can be constructed' do
allow(repository).to receive(:full_path).and_return(nil) allow(repository).to receive(:full_path).and_return(nil)
expect(repository.exists?).to eq(false) expect(repository.exists?).to be(false)
end end
context 'with broken storage', :broken_storage do context 'with broken storage', :broken_storage do
...@@ -1242,16 +1242,6 @@ describe Repository do ...@@ -1242,16 +1242,6 @@ describe Repository do
end end
end end
describe '#exists?' do
context 'when repository_exists is disabled' do
it_behaves_like 'repo exists check'
end
context 'when repository_exists is enabled', :skip_gitaly_mock do
it_behaves_like 'repo exists check'
end
end
describe '#has_visible_content?' do describe '#has_visible_content?' do
before do before do
# If raw_repository.has_visible_content? gets called more than once then # If raw_repository.has_visible_content? gets called more than once then
......
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