Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-11-08 20:42:13 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-11-21 14:51:40 +0300
commit6f393877e555c9e87017747cd70d3577bb70a03e (patch)
tree8c73554988332d33550f788bc69c951c3f8c3e5e /spec/models/repository_spec.rb
parentdf5548e19e8c988b709e66a7e35ddc097344913e (diff)
Use File.exist? to check if a repository exists
Initializing Rugged objects is way too expensive just to check if a repository exists. Even though we cache this data once in a while we have to refresh this. On GitLab.com we have seen Repository#exists? taking up to _1 minute_ to complete in the absolute worst case, though usually it sits around a second or so. Using File.exist? to instead check if $GIT_DIR/refs exists is a much faster way of checking if a repository was initialized properly.
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r--spec/models/repository_spec.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 5e8a7bb08a1..635130cf797 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -811,8 +811,7 @@ describe Repository, models: true do
end
it 'returns false when a repository does not exist' do
- expect(repository.raw_repository).to receive(:rugged).
- and_raise(Gitlab::Git::Repository::NoRepository)
+ allow(repository).to receive(:refs_directory_exists?).and_return(false)
expect(repository.exists?).to eq(false)
end