Commit f3cf40b8 authored by Sean McGivern's avatar Sean McGivern Committed by Fatih Acet

Handle case where one side deleted the file

parent 10cf933f
...@@ -140,7 +140,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -140,7 +140,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format.json do format.json do
begin begin
render json: Gitlab::Conflict::FileCollection.new(@merge_request) render json: Gitlab::Conflict::FileCollection.new(@merge_request)
rescue Gitlab::Conflict::Parser::ParserError => e rescue Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing => e
render json: { message: 'Unable to resolve conflicts in the web interface for this merge request' } render json: { message: 'Unable to resolve conflicts in the web interface for this merge request' }
end end
end end
......
module Gitlab module Gitlab
module Conflict module Conflict
class FileCollection class FileCollection
class ConflictSideMissing < StandardError
end
attr_reader :merge_request, :our_commit, :their_commit attr_reader :merge_request, :our_commit, :their_commit
def initialize(merge_request) def initialize(merge_request)
...@@ -39,10 +42,9 @@ module Gitlab ...@@ -39,10 +42,9 @@ module Gitlab
def files def files
@files ||= merge_index.conflicts.map do |conflict| @files ||= merge_index.conflicts.map do |conflict|
their_path = conflict[:theirs][:path] raise ConflictSideMissing unless conflict[:theirs] && conflict[:ours]
our_path = conflict[:ours][:path]
Gitlab::Conflict::File.new(merge_index.merge_file(our_path), Gitlab::Conflict::File.new(merge_index.merge_file(conflict[:ours][:path]),
conflict, conflict,
diff_refs: merge_request.diff_refs, diff_refs: merge_request.diff_refs,
repository: repository) repository: repository)
......
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