Commit 6f7a3ee6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor merge request version compare feature

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5f0535ac
...@@ -542,7 +542,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -542,7 +542,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def compared_diff_version def compared_diff_version
compare = CompareService.new.execute(@project, @merge_request_diff.head_commit_sha, @project, @start_sha) compare = @merge_request_diff.compare_with(@start_sha)
if compare if compare
@diffs = compare.diffs(diff_options) @diffs = compare.diffs(diff_options)
...@@ -551,11 +551,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -551,11 +551,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def original_diff_version def original_diff_version
unless @merge_request_diff.latest? @diff_notes_disabled = !@merge_request_diff.latest?
# Disable comments if browsing older version of the diff
@diff_notes_disabled = true
end
@diffs = @merge_request_diff.diffs(diff_options) @diffs = @merge_request_diff.diffs(diff_options)
end end
end end
...@@ -152,6 +152,10 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -152,6 +152,10 @@ class MergeRequestDiff < ActiveRecord::Base
self == merge_request.merge_request_diff self == merge_request.merge_request_diff
end end
def compare_with(sha)
CompareService.new.execute(project, head_commit_sha, project, sha)
end
private private
def dump_commits(commits) def dump_commits(commits)
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
= time_ago_with_tooltip(merge_request_diff.created_at) = time_ago_with_tooltip(merge_request_diff.created_at)
- if @merge_request_diff.base_commit_sha - if @merge_request_diff.base_commit_sha
&nbsp;and&nbsp; and
%span.dropdown.inline.mr-version-compare-dropdown %span.dropdown.inline.mr-version-compare-dropdown
%a.btn-link.dropdown-toggle{ data: {toggle: :dropdown} } %a.btn-link.dropdown-toggle{ data: {toggle: :dropdown} }
%strong %strong
...@@ -51,8 +51,10 @@ ...@@ -51,8 +51,10 @@
#{@merge_request.target_branch} (base) #{@merge_request.target_branch} (base)
.monospace #{short_sha(@merge_request_diff.base_commit_sha)} .monospace #{short_sha(@merge_request_diff.base_commit_sha)}
- unless @merge_request_diff.latest? && !@start_sha - unless @merge_request_diff.latest? && !@start_sha
.prepend-top-10 .prepend-top-10
= icon('info-circle') = icon('info-circle')
Comments are disabled while viewing outdated merge versions or comparing to versions other than base. - if @start_sha
Comments are disabled because you're comparing two versions of this merge request.
- else
Comments are disabled because you're viewing an old version of this merge request.
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