Commit 674b926e authored by John Cai's avatar John Cai

Guard against nil dereferenced_target

parent 9d7ff90d
---
title: Guard against nil dereferenced_target
merge_request: 27192
author:
type: fixed
...@@ -466,7 +466,7 @@ module Gitlab ...@@ -466,7 +466,7 @@ module Gitlab
@refs_hash = Hash.new { |h, k| h[k] = [] } @refs_hash = Hash.new { |h, k| h[k] = [] }
(tags + branches).each do |ref| (tags + branches).each do |ref|
next unless ref.target && ref.name next unless ref.target && ref.name && ref.dereferenced_target&.id
@refs_hash[ref.dereferenced_target.id] << ref.name @refs_hash[ref.dereferenced_target.id] << ref.name
end end
......
...@@ -531,6 +531,13 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -531,6 +531,13 @@ describe Gitlab::Git::Repository, :seed_helper do
it 'has valid commit ids as keys' do it 'has valid commit ids as keys' do
expect(subject.keys).to all( match(Commit::COMMIT_SHA_PATTERN) ) expect(subject.keys).to all( match(Commit::COMMIT_SHA_PATTERN) )
end end
it 'does not error when dereferenced_target is nil' do
blob_id = repository.blob_at('master', 'README.md').id
repository_rugged.tags.create("refs/tags/blob-tag", blob_id)
expect { subject }.not_to raise_error
end
end end
describe '#fetch_repository_as_mirror' do describe '#fetch_repository_as_mirror' do
......
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