Skip to content
Snippets Groups Projects
Commit b0535009 authored by Stan Hu's avatar Stan Hu
Browse files

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
parent a407bba8
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment