Commit ae5748a7 authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch 'rugged-reference-cache-rescue' into 'master'

Stop rescuing Rugged::Reference in Repository cache

See merge request gitlab-org/gitlab-ce!16770
......@@ -951,7 +951,7 @@ def cache_method_output(key, fallback: nil, memoize_only: false, &block)
end
instance_variable_set(ivar, value)
rescue Rugged::ReferenceError, Gitlab::Git::Repository::NoRepository
rescue Gitlab::Git::Repository::NoRepository
# Even if the above `#exists?` check passes these errors might still
# occur (for example because of a non-existing HEAD). We want to
# gracefully handle this and not cache anything
......
......@@ -83,6 +83,8 @@ def tree_entries_from_rugged(repository, sha, path)
commit_id: sha
)
end
rescue Rugged::ReferenceError
[]
end
end
......
......@@ -80,22 +80,18 @@
end
describe '#where' do
context 'with gitaly disabled' do
before do
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false)
end
it 'calls #tree_entries_from_rugged' do
expect(described_class).to receive(:tree_entries_from_rugged)
described_class.where(repository, SeedRepo::Commit::ID, '/')
shared_examples '#where' do
it 'returns an empty array when called with an invalid ref' do
expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([])
end
end
it 'gets the tree entries from GitalyClient' do
expect_any_instance_of(Gitlab::GitalyClient::CommitService).to receive(:tree_entries)
context 'with gitaly' do
it_behaves_like '#where'
end
described_class.where(repository, SeedRepo::Commit::ID, '/')
context 'without gitaly', :skip_gitaly_mock do
it_behaves_like '#where'
end
end
end
......@@ -772,8 +772,7 @@ def expect_to_raise_storage_error
user, 'LICENSE', 'Copyright!',
message: 'Add LICENSE', branch_name: 'master')
allow(repository).to receive(:file_on_head)
.and_raise(Rugged::ReferenceError)
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.license_blob).to be_nil
end
......@@ -885,7 +884,7 @@ def expect_to_raise_storage_error
end
it 'returns nil for empty repository' do
allow(repository).to receive(:file_on_head).and_raise(Rugged::ReferenceError)
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.gitlab_ci_yml).to be_nil
end
end
......@@ -1937,8 +1936,7 @@ def merge(repository, user, merge_request, message)
describe '#avatar' do
it 'returns nil if repo does not exist' do
expect(repository).to receive(:file_on_head)
.and_raise(Rugged::ReferenceError)
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.avatar).to eq(nil)
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