BigW Consortium Gitlab

Commit e2d7eb88 by Regis Boudinot

Merge branch 'dm-no-conflicts-when-branches-are-missing-9-2' into '9-2-stable'

Stop MR conflict code from blowing up when branches are missing (9.2) See merge request !11502
parents 8e225051 b8ca5c78
......@@ -299,6 +299,8 @@ class MergeRequest < ActiveRecord::Base
attr_writer :target_branch_sha, :source_branch_sha
def source_branch_head
return unless source_project
source_branch_ref = @source_branch_sha || source_branch
source_project.repository.commit(source_branch_ref) if source_branch_ref
end
......@@ -919,6 +921,7 @@ class MergeRequest < ActiveRecord::Base
return @conflicts_can_be_resolved_in_ui = false unless cannot_be_merged?
return @conflicts_can_be_resolved_in_ui = false unless has_complete_diff_refs?
return @conflicts_can_be_resolved_in_ui = false if branch_missing?
begin
# Try to parse each conflict. If the MR's mergeable status hasn't been updated,
......
......@@ -16,7 +16,7 @@ module Gitlab
end
def trace(old_position)
return unless old_diff_refs.complete? && new_diff_refs.complete?
return unless old_diff_refs&.complete? && new_diff_refs&.complete?
return unless old_position.diff_refs == old_diff_refs
# Suppose we have an MR with source branch `feature` and target branch `master`.
......
......@@ -1335,6 +1335,13 @@ describe MergeRequest, models: true do
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when one of the MR branches is missing' do
merge_request = create_merge_request('conflict-resolvable')
merge_request.project.repository.rm_branch(merge_request.author, 'conflict-resolvable')
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the MR has a missing ref after a force push' do
merge_request = create_merge_request('conflict-resolvable')
allow(merge_request.conflicts).to receive(:merge_index).and_raise(Rugged::OdbError)
......
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