Compare merge request version against other version on changes page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
9b5a83816e
commit
8b2e065b7b
3 changed files with 34 additions and 13 deletions
|
@ -98,7 +98,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
@diff_notes_disabled = true
|
||||
end
|
||||
|
||||
@diffs = @merge_request_diff.diffs(diff_options)
|
||||
if params[:start_sha].present?
|
||||
compare_diff_version
|
||||
else
|
||||
@diffs = @merge_request_diff.diffs(diff_options)
|
||||
end
|
||||
|
||||
render json: { html: view_to_html_string("projects/merge_requests/show/_diffs") }
|
||||
end
|
||||
|
@ -529,4 +533,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
params[:merge_request] ||= ActionController::Parameters.new(source_project: @project)
|
||||
@merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute
|
||||
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
|
||||
|
|
|
@ -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?
|
||||
end
|
||||
|
||||
def compare_versions_path(project, version, base_version)
|
||||
namespace_project_compare_path(project.namespace, project, base_version.head_commit_sha, version.head_commit_sha)
|
||||
def mr_version_path(project, merge_request, merge_request_diff, start_sha = nil)
|
||||
diffs_namespace_project_merge_request_path(
|
||||
project.namespace, project, merge_request,
|
||||
diff_id: merge_request_diff.id, start_sha: start_sha)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,28 +26,32 @@
|
|||
Compared with:
|
||||
%span.dropdown.inline
|
||||
%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
|
||||
%ul.dropdown-menu.dropdown-menu-selectable
|
||||
- merge_request_diffs.each do |merge_request_diff|
|
||||
- next if merge_request_diff.id >= @merge_request_diff.id
|
||||
%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
|
||||
#{merge_request_diff.head_commit.short_id}
|
||||
%br
|
||||
%small
|
||||
= time_ago_with_tooltip(merge_request_diff.created_at)
|
||||
%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
|
||||
base
|
||||
|
||||
- unless @merge_request_diff.latest?
|
||||
%span.prepend-left-default
|
||||
= icon('info-circle')
|
||||
This version is not the latest one. Comments are disabled
|
||||
|
||||
.pull-right
|
||||
%span.monospace
|
||||
#{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id}
|
||||
- unless @merge_request_diff.latest? && params[:start_sha].blank?
|
||||
.pull-right
|
||||
= icon('info-circle')
|
||||
- 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
|
||||
|
|
Loading…
Reference in a new issue