BigW Consortium Gitlab

Make merge request diff works with new FileCollection logic

parent 5e95c0b8
......@@ -91,7 +91,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to do |format|
format.html { define_discussion_vars }
format.json do
@diffs = @merge_request.diffs(diff_options)
@diffs = @merge_request_diff.diffs(diff_options)
render json: { html: view_to_html_string("projects/merge_requests/show/_diffs") }
end
......
......@@ -172,10 +172,10 @@ class MergeRequest < ActiveRecord::Base
end
def diffs(diff_options = nil)
if self.compare
self.compare.diffs(diff_options)
if compare
compare.diffs(diff_options)
else
Gitlab::Diff::FileCollection::MergeRequest.new(self, diff_options: diff_options)
merge_request_diff.diffs(diff_options)
end
end
......
......@@ -141,7 +141,13 @@ class MergeRequestDiff < ActiveRecord::Base
base_commit_sha? && head_commit_sha? && start_commit_sha?
end
private
def diffs(diff_options = nil)
Gitlab::Diff::FileCollection::MergeRequestDiff.new(self, diff_options: diff_options)
end
def project
merge_request.target_project
end
def compare
@compare ||=
......@@ -157,6 +163,8 @@ class MergeRequestDiff < ActiveRecord::Base
end
end
private
def dump_commits(commits)
commits.map(&:to_hash)
end
......@@ -229,10 +237,6 @@ class MergeRequestDiff < ActiveRecord::Base
update_columns_serialized(new_attributes)
end
def project
merge_request.target_project
end
def repository
project.repository
end
......
- if @merge_request_diff.collected?
= render 'projects/merge_requests/show/versions'
= render "projects/diffs/diffs", diffs: @diffs
- elsif @merge_request_diff.empty?
.nothing-here-block Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch}
......
module Gitlab
module Diff
module FileCollection
class MergeRequest < Base
def initialize(merge_request, diff_options:)
@merge_request = merge_request
class MergeRequestDiff < Base
def initialize(merge_request_diff, diff_options:)
@merge_request_diff = merge_request_diff
super(merge_request,
project: merge_request.project,
super(merge_request_diff,
project: merge_request_diff.project,
diff_options: diff_options,
diff_refs: merge_request.diff_refs)
diff_refs: merge_request_diff.diff_refs)
end
def diff_files
......@@ -61,11 +61,11 @@ module Gitlab
end
def cacheable?
@merge_request.merge_request_diff.present?
@merge_request_diff.present?
end
def cache_key
[@merge_request.merge_request_diff, 'highlighted-diff-files', diff_options]
[@merge_request_diff, 'highlighted-diff-files', diff_options]
end
end
end
......
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