Add ability to render different merge request versions
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
94ca25c9b8
commit
b8fef7eb59
4 changed files with 38 additions and 3 deletions
|
@ -81,7 +81,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
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 @@ class MergeRequestDiff < ActiveRecord::Base
|
|||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
- 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
|
||||
|
|
18
app/views/projects/merge_requests/show/_versions.html.haml
Normal file
18
app/views/projects/merge_requests/show/_versions.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- 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)
|
Loading…
Reference in a new issue