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:
authorStan Hu <stanhu@gmail.com>2018-04-15 00:34:39 +0300
committerStan Hu <stanhu@gmail.com>2018-04-15 00:37:28 +0300
commitb1f15dfa42fb7b8f74a439806f004eaa5ed598a8 (patch)
tree8a8794cf8a991fee55f7e55ddbd3bcdb091edd3e /spec/lib/gitlab/git
parent160f1fd225944b4cedd9d5223cdc55b2f3ed0ea7 (diff)
Memoize Git::Repository#has_visible_content?
This is called repeatedly when viewing a merge request, and this should improve performance significantly by avoiding shelling out to git every time. This should help https://gitlab.com/gitlab-com/infrastructure/issues/4027.
Diffstat (limited to 'spec/lib/gitlab/git')
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 1e00e8d2739..f6bf7a162f6 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -463,7 +463,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
it 'returns false when there are no branches' do
# Sanity check
- expect(repository.has_local_branches?).to eq(true)
+ expect(repository.uncached_has_local_branches?).to eq(true)
FileUtils.rm_rf(File.join(repository.path, 'packed-refs'))
heads_dir = File.join(repository.path, 'refs/heads')
@@ -473,6 +473,16 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect(repository.has_local_branches?).to eq(false)
end
end
+
+ context 'memoizes the value' do
+ it 'returns true' do
+ expect(repository).to receive(:uncached_has_local_branches?).once.and_call_original
+
+ 2.times do
+ expect(repository.has_local_branches?).to eq(true)
+ end
+ end
+ end
end
context 'with gitaly' do