Fix MergeRequestService erroring out on deleted branch
When a branch is deleted, the push commit IDs is an empty array. The previous change would attempt to call `[].exists?`, which is invalid. Fix this by returning `MergeRequestDiffCommit.none` instead. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53853
This commit is contained in:
parent
a407bba81a
commit
b053500902
|
@ -142,7 +142,7 @@ class MergeRequestDiff < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def commits_by_shas(shas)
|
||||
return [] unless shas.present?
|
||||
return MergeRequestDiffCommit.none unless shas.present?
|
||||
|
||||
merge_request_diff_commits.where(sha: shas)
|
||||
end
|
||||
|
|
|
@ -2650,6 +2650,10 @@ describe MergeRequest do
|
|||
end
|
||||
|
||||
describe '#includes_any_commits?' do
|
||||
it 'returns false' do
|
||||
expect(subject.includes_any_commits?([])).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(subject.includes_any_commits?([Gitlab::Git::BLANK_SHA])).to be_falsey
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue