Handle case where one side deleted the file

This commit is contained in:
Sean McGivern 2016-08-01 14:52:53 +01:00 committed by Fatih Acet
parent 10cf933f70
commit f3cf40b8aa
2 changed files with 6 additions and 4 deletions

View File

@ -140,7 +140,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format.json do
begin
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' }
end
end

View File

@ -1,6 +1,9 @@
module Gitlab
module Conflict
class FileCollection
class ConflictSideMissing < StandardError
end
attr_reader :merge_request, :our_commit, :their_commit
def initialize(merge_request)
@ -39,10 +42,9 @@ module Gitlab
def files
@files ||= merge_index.conflicts.map do |conflict|
their_path = conflict[:theirs][:path]
our_path = conflict[:ours][:path]
raise ConflictSideMissing unless conflict[:theirs] && conflict[:ours]
Gitlab::Conflict::File.new(merge_index.merge_file(our_path),
Gitlab::Conflict::File.new(merge_index.merge_file(conflict[:ours][:path]),
conflict,
diff_refs: merge_request.diff_refs,
repository: repository)