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/helpers/diff_helper.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/helpers/diff_helper.rb')
-rw-r--r-- | app/helpers/diff_helper.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index eb57516247d..d4655d60799 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -8,6 +8,25 @@ module DiffHelper [marked_old_line, marked_new_line] end + def render_diff_for_path(diffs, diff_refs, project) + diff_file = safe_diff_files(diffs, diff_refs).first + + return render_404 unless diff_file + + diff_commit = commit_for_diff(diff_file) + blob = project.repository.blob_for_diff(diff_commit, diff_file) + + locals = { + diff_file: diff_file, + diff_commit: diff_commit, + diff_refs: diff_refs, + blob: blob, + project: project + } + + render json: { html: view_to_html_string('projects/diffs/_content', locals) } + end + def diff_view diff_views = %w(inline parallel) |