Commit 8b2e065b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Compare merge request version against other version on changes page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 9b5a8381
...@@ -98,7 +98,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -98,7 +98,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diff_notes_disabled = true @diff_notes_disabled = true
end end
if params[:start_sha].present?
compare_diff_version
else
@diffs = @merge_request_diff.diffs(diff_options) @diffs = @merge_request_diff.diffs(diff_options)
end
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
...@@ -529,4 +533,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -529,4 +533,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
params[:merge_request] ||= ActionController::Parameters.new(source_project: @project) params[:merge_request] ||= ActionController::Parameters.new(source_project: @project)
@merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute @merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute
end end
def compare_diff_version
@compare = CompareService.new.execute(@project, @merge_request_diff.head_commit_sha, @project, params[:start_sha])
if @compare
@commits = @compare.commits
@commit = @compare.commit
@diffs = @compare.diffs(diff_options)
@diff_notes_disabled = true
end
end
end end
...@@ -101,7 +101,9 @@ module MergeRequestsHelper ...@@ -101,7 +101,9 @@ module MergeRequestsHelper
return 'hidden' if merge_request.closed? == closed || (merge_request.merged? == closed && !merge_request.closed?) || merge_request.closed_without_fork? return 'hidden' if merge_request.closed? == closed || (merge_request.merged? == closed && !merge_request.closed?) || merge_request.closed_without_fork?
end end
def compare_versions_path(project, version, base_version) def mr_version_path(project, merge_request, merge_request_diff, start_sha = nil)
namespace_project_compare_path(project.namespace, project, base_version.head_commit_sha, version.head_commit_sha) diffs_namespace_project_merge_request_path(
project.namespace, project, merge_request,
diff_id: merge_request_diff.id, start_sha: start_sha)
end end
end end
...@@ -26,28 +26,32 @@ ...@@ -26,28 +26,32 @@
Compared with: Compared with:
%span.dropdown.inline %span.dropdown.inline
%a.btn-link.dropdown-toggle{ data: {toggle: :dropdown} } %a.btn-link.dropdown-toggle{ data: {toggle: :dropdown} }
%strong.monospace base %strong.monospace<
- if params[:start_sha].present?
#{params[:start_sha][0...8]}
- else
#{"base"}
%span.caret %span.caret
%ul.dropdown-menu.dropdown-menu-selectable %ul.dropdown-menu.dropdown-menu-selectable
- merge_request_diffs.each do |merge_request_diff| - merge_request_diffs.each do |merge_request_diff|
- next if merge_request_diff.id >= @merge_request_diff.id - next if merge_request_diff.id >= @merge_request_diff.id
%li %li
= link_to compare_versions_path(@project, @merge_request_diff, merge_request_diff), class: ('is-active' if merge_request_diff == @base_version), target: '_blank' do = link_to mr_version_path(@project, @merge_request, @merge_request_diff, merge_request_diff.head_commit_sha), class: ('is-active' if merge_request_diff.head_commit_sha == params[:start_sha]) do
%strong.monospace %strong.monospace
#{merge_request_diff.head_commit.short_id} #{merge_request_diff.head_commit.short_id}
%br %br
%small %small
= time_ago_with_tooltip(merge_request_diff.created_at) = time_ago_with_tooltip(merge_request_diff.created_at)
%li %li
= link_to '#', class: 'is-active' do = link_to mr_version_path(@project, @merge_request, @merge_request_diff), class: ('is-active' unless params[:start_sha].present?) do
%strong.monospace %strong.monospace
base base
- unless @merge_request_diff.latest?
%span.prepend-left-default
= icon('info-circle')
This version is not the latest one. Comments are disabled
- unless @merge_request_diff.latest? && params[:start_sha].blank?
.pull-right .pull-right
%span.monospace = icon('info-circle')
#{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id} - if params[:start_sha].present?
Comments are disabled when compare with version different from base
- else
This version is not the latest one. Comments are disabled
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