diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-08-31 18:14:14 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-09-07 10:22:57 +0300 |
commit | 8b2e065b7b878b27f0494248b3734381291a67bd (patch) | |
tree | 3a8154369d46a49df711e7b7a92d3f9708c4cb7a /app | |
parent | 9b5a83816ec96b4c3a896c3d7c5edf358e62622f (diff) | |
download | gitlab-ce-8b2e065b7b878b27f0494248b3734381291a67bd.tar.gz |
Compare merge request version against other version on changes page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 17 | ||||
-rw-r--r-- | app/helpers/merge_requests_helper.rb | 6 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_versions.html.haml | 24 |
3 files changed, 34 insertions, 13 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 4f9ca0097a1..2fa55b83c0e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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 diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index d5470d5d3c8..1379180cb6e 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -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 diff --git a/app/views/projects/merge_requests/show/_versions.html.haml b/app/views/projects/merge_requests/show/_versions.html.haml index d2a70bcc716..13bec019988 100644 --- a/app/views/projects/merge_requests/show/_versions.html.haml +++ b/app/views/projects/merge_requests/show/_versions.html.haml @@ -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 |