summaryrefslogtreecommitdiff
path: root/app/controllers/projects/compare_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/compare_controller.rb')
-rw-r--r--app/controllers/projects/compare_controller.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index d240b9fe989..8a04f63f4d4 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -6,7 +6,7 @@ class Projects::CompareController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_download_code!
- before_action :assign_ref_vars, only: [:index, :show]
+ before_action :assign_ref_vars, only: [:index, :show, :diff_for_path]
before_action :merge_request, only: [:index, :show]
def index
@@ -35,6 +35,22 @@ class Projects::CompareController < Projects::ApplicationController
end
end
+ def diff_for_path
+ compare = CompareService.new.
+ execute(@project, @head_ref, @project, @base_ref, diff_options)
+
+ return render_404 unless compare
+
+ @commit = @project.commit(@head_ref)
+ @base_commit = @project.merge_base_commit(@base_ref, @head_ref)
+ diffs = compare.diffs(diff_options.merge(paths: [params[:path]]))
+
+ @diff_notes_disabled = true
+ @grouped_diff_notes = {}
+
+ render_diff_for_path(diffs, [@base_commit, @commit], @project)
+ end
+
def create
redirect_to namespace_project_compare_path(@project.namespace, @project,
params[:from], params[:to])