Commit c1834664 authored by Stan Hu's avatar Stan Hu

Merge branch 'handle-avatar-in-empty-repo' into 'master'

Don't attempt to look up an avatar in repo if repo directory does not exist

Relates to https://sentry.gitlap.com/gitlab/gitlabcom/issues/3507/

Closes #14580



See merge request !3390
parents 8034e1a1 50687897
Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased)
- Don't attempt to look up an avatar in repo if repo directory does not exist (Stan hu)
- Preserve time notes/comments have been updated at when moving issue
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Fix avatar stretching by providing a cropping feature
......
......@@ -889,6 +889,8 @@ class Repository
end
def avatar
return nil unless exists?
@avatar ||= cache.fetch(:avatar) do
AVATAR_FILES.find do |file|
blob_at_branch('master', file)
......
......@@ -422,6 +422,12 @@ describe Project, models: true do
it { should eq "http://localhost#{avatar_path}" }
end
context 'when git repo is empty' do
let(:project) { create(:empty_project) }
it { should eq nil }
end
end
describe :ci_commit do
......
......@@ -744,6 +744,12 @@ describe Repository, models: true do
end
describe '#avatar' do
it 'returns nil if repo does not exist' do
expect(repository).to receive(:exists?).and_return(false)
expect(repository.avatar).to eq(nil)
end
it 'returns the first avatar file found in the repository' do
expect(repository).to receive(:blob_at_branch).
with('master', 'logo.png').
......
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