diff options
author | Sean McGivern <sean@gitlab.com> | 2016-06-28 17:25:32 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-08 10:56:55 +0100 |
commit | b6b26692ea44cfeab7e8fd64b7df60852850fce2 (patch) | |
tree | 3f54b14b7b8500d0182d7e5eca653b313eec17e2 /app/controllers/projects/compare_controller.rb | |
parent | 2c650b6f30d2e76cf632d6ce5771859aed67ac48 (diff) | |
download | gitlab-ce-b6b26692ea44cfeab7e8fd64b7df60852850fce2.tar.gz |
Collapse large diffs by default
When rendering a list of diff files, skip those where the diff is over
10 KB and provide an endpoint to render individually instead.
Diffstat (limited to 'app/controllers/projects/compare_controller.rb')
-rw-r--r-- | app/controllers/projects/compare_controller.rb | 18 |
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]) |