diff options
-rw-r--r-- | changelogs/unreleased/zj-repository-exist-mandatory.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 10 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 16 |
3 files changed, 9 insertions, 22 deletions
diff --git a/changelogs/unreleased/zj-repository-exist-mandatory.yml b/changelogs/unreleased/zj-repository-exist-mandatory.yml new file mode 100644 index 00000000000..7d83446e90f --- /dev/null +++ b/changelogs/unreleased/zj-repository-exist-mandatory.yml @@ -0,0 +1,5 @@ +--- +title: Repository#exists? is always executed through Gitaly +merge_request: +author: +type: performance diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 5a6e2e0b937..0d07fb85213 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -142,15 +142,7 @@ module Gitlab end def exists? - Gitlab::GitalyClient.migrate(:repository_exists, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled| - if enabled - gitaly_repository_client.exists? - else - circuit_breaker.perform do - File.exist?(File.join(path, 'refs')) - end - end - end + gitaly_repository_client.exists? end # Returns an Array of branch names diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index e45fe7db1e7..630b9e0519f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1224,15 +1224,15 @@ describe Repository do end end - shared_examples 'repo exists check' do + describe '#exists?' do it 'returns true when a repository exists' do - expect(repository.exists?).to eq(true) + expect(repository.exists?).to be(true) end it 'returns false if no full path can be constructed' do allow(repository).to receive(:full_path).and_return(nil) - expect(repository.exists?).to eq(false) + expect(repository.exists?).to be(false) end context 'with broken storage', :broken_storage do @@ -1242,16 +1242,6 @@ describe Repository do 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 before do # If raw_repository.has_visible_content? gets called more than once then |