Commit 643a368f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make merge request diff works with new FileCollection logic

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