Commit b8fef7eb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add ability to render different merge request versions

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 94ca25c9
......@@ -81,7 +81,13 @@ def show
def diffs
apply_diff_view_cookie!
@merge_request_diff = @merge_request.merge_request_diff
@merge_request_diff =
if params[:diff_id]
@merge_request.merge_request_diffs.find(params[:diff_id])
else
@merge_request.merge_request_diff
end
respond_to do |format|
format.html { define_discussion_vars }
......
......@@ -96,6 +96,16 @@ def compare
end
end
def diff_refs
return unless start_commit || base_commit
Gitlab::Diff::DiffRefs.new(
base_sha: base_commit_sha,
start_sha: start_commit_sha,
head_sha: head_commit_sha
)
end
private
# Collect array of Git::Commit objects
......
- if @merge_request_diff.collected?
= render "projects/diffs/diffs", diffs: @merge_request.diffs(diff_options),
project: @merge_request.project, diff_refs: @merge_request.diff_refs
= render 'projects/merge_requests/show/versions'
= render "projects/diffs/diffs", diffs: @merge_request_diff.diffs(diff_options),
project: @merge_request.project, diff_refs: @merge_request_diff.diff_refs
- elsif @merge_request_diff.empty?
.nothing-here-block Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch}
- else
......
- if @merge_request.merge_request_diffs.size > 1
- latest_diff = @merge_request.merge_request_diff
.light-well
Merge Request version
%span.dropdown.inline
%a.dropdown-toggle{ data: {toggle: :dropdown} }
%strong.monospace #{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id}
%span.caret
%ul.dropdown-menu
- @merge_request.merge_request_diffs.each do |merge_request_diff|
%li{ class: ('active' if merge_request_diff == latest_diff) }
= link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, diff_id: merge_request_diff.id) do
%strong.monospace
#{merge_request_diff.base_commit.short_id}..#{merge_request_diff.head_commit.short_id}
%br
%small
= time_ago_with_tooltip(merge_request_diff.created_at)
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