Commit 06896634 authored by Yorick Peterse's avatar Yorick Peterse

Use branch_count in Repository#has_visible_content?

Gitlab::Git::Repository#branch_count is a tad faster than the previous
setup. See gitlab-org/gitlab_git!62 for more information.
parent d21d8e57
......@@ -57,7 +57,7 @@ class Repository
# This method return true if repository contains some content visible in project page.
#
def has_visible_content?
!raw_repository.branches.empty?
raw_repository.branch_count > 0
end
def commit(id = 'HEAD')
......
......@@ -219,4 +219,24 @@ describe Repository, models: true do
end
end
end
describe '#has_visible_content?' do
subject { repository.has_visible_content? }
describe 'when there are no branches' do
before do
allow(repository.raw_repository).to receive(:branch_count).and_return(0)
end
it { is_expected.to eq(false) }
end
describe 'when there are branches' do
before do
allow(repository.raw_repository).to receive(:branch_count).and_return(3)
end
it { is_expected.to eq(true) }
end
end
end
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