Skip to content
Snippets Groups Projects
Commit b8ca5c78 authored by Douwe Maan's avatar Douwe Maan
Browse files

Stop MR conflict code from blowing up when branches are missing

parent 3114147b
No related branches found
No related tags found
2 merge requests!12258Update Prometheus Merge Request Metrics page,!11502Stop MR conflict code from blowing up when branches are missing (9.2)
Pipeline #
Loading
Loading
@@ -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
Loading
Loading
@@ -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,
Loading
Loading
Loading
Loading
@@ -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`.
Loading
Loading
Loading
Loading
@@ -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)
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