Commit c8563a11 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'ld-remove-check-for-if-repository-exists' into 'master'

Remove redundant Repository#exists? checks

See merge request gitlab-org/gitlab!22640
parents 5faba4f5 a6eff1c1
......@@ -143,7 +143,7 @@ module SearchHelper
# Autocomplete results for the current project, if it's defined
def project_autocomplete
if @project && @project.repository.exists? && @project.repository.root_ref
if @project && @project.repository.root_ref
ref = @ref || @project.repository.root_ref
[
......
......@@ -1514,7 +1514,7 @@ class Project < ApplicationRecord
end
def default_branch
@default_branch ||= repository.root_ref if repository.exists?
@default_branch ||= repository.root_ref
end
def reload_default_branch
......
......@@ -1331,6 +1331,13 @@ describe Repository do
repository.root_ref
end
it 'returns nil if the repository does not exist' do
repository = create(:project).repository
expect(repository).not_to be_exists
expect(repository.root_ref).to be_nil
end
it_behaves_like 'asymmetric cached method', :root_ref
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