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/commit_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/commit_controller.rb')
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 37d6521026c..810653b4264 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -19,7 +19,7 @@ class Projects::CommitController < Projects::ApplicationController @grouped_diff_notes = commit.notes.grouped_diff_notes @notes = commit.notes.non_diff_notes.fresh - + Banzai::NoteRenderer.render( @grouped_diff_notes.values.flatten + @notes, @project, @@ -41,6 +41,24 @@ class Projects::CommitController < Projects::ApplicationController end end + def diff_for_path + return git_not_found! unless commit + + opts = diff_options + opts[:ignore_whitespace_change] = true if params[:format] == 'diff' + + diffs = commit.diffs(opts.merge(paths: [params[:path]])) + diff_refs = [commit.parent || commit, commit] + + @comments_target = { + noteable_type: 'Commit', + commit_id: @commit.id + } + @grouped_diff_notes = {} + + render_diff_for_path(diffs, diff_refs, @project) + end + def builds end |