Commit 67beaf6f authored by Sean McGivern's avatar Sean McGivern

Don't show conflicts when there are none

parent 4a3d1a58
...@@ -777,7 +777,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -777,7 +777,11 @@ class MergeRequest < ActiveRecord::Base
return @conflicts_can_be_resolved_in_ui = false unless has_complete_diff_refs? return @conflicts_can_be_resolved_in_ui = false unless has_complete_diff_refs?
begin begin
@conflicts_can_be_resolved_in_ui = conflicts.files.each(&:lines) # Try to parse each conflict. If the MR's mergeable status hasn't been updated,
# ensure that we don't say there are conflicts to resolve when there are no conflict
# files.
conflicts.files.each(&:lines)
@conflicts_can_be_resolved_in_ui = conflicts.files.length > 0
rescue Rugged::OdbError, Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing rescue Rugged::OdbError, Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing
@conflicts_can_be_resolved_in_ui = false @conflicts_can_be_resolved_in_ui = false
end end
......
...@@ -890,6 +890,12 @@ describe MergeRequest, models: true do ...@@ -890,6 +890,12 @@ describe MergeRequest, models: true do
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end end
it 'returns a falsey value when the MR is marked as having conflicts, but has none' do
merge_request = create_merge_request('master')
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 it 'returns a falsey value when the MR has a missing ref after a force push' do
merge_request = create_merge_request('conflict-resolvable') merge_request = create_merge_request('conflict-resolvable')
allow(merge_request.conflicts).to receive(:merge_index).and_raise(Rugged::OdbError) 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