Handling big commits & big diff
This commit is contained in:
parent
17a88bb6a2
commit
86676476e6
7 changed files with 85 additions and 53 deletions
|
@ -74,3 +74,8 @@ function resetMenu() {
|
|||
function slugify(text) {
|
||||
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
|
||||
}
|
||||
|
||||
function showDiff(link) {
|
||||
$(link).next('table').show();
|
||||
$(link).remove();
|
||||
}
|
||||
|
|
|
@ -17,9 +17,15 @@ a {
|
|||
&.lined {
|
||||
text-decoration:underlined;
|
||||
}
|
||||
&.supp_diff_link {
|
||||
text-align:center;
|
||||
padding:20px 0;
|
||||
background:#f1f1f1;
|
||||
width:100%;
|
||||
float:left;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.btn {
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f1f1f1), color-stop(25%, #f1f1f1), to(#e6e6e6));
|
||||
background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 25%, #e6e6e6);
|
||||
|
|
|
@ -34,6 +34,10 @@ class CommitsController < ApplicationController
|
|||
@line_notes = project.commit_line_notes(@commit)
|
||||
|
||||
@notes_count = @line_notes.count + project.commit_notes(@commit).count
|
||||
|
||||
if @commit.diffs.size > 200 && !params[:force_show_diff]
|
||||
@suppress_diff = true
|
||||
end
|
||||
end
|
||||
|
||||
def compare
|
||||
|
|
|
@ -1,26 +1,40 @@
|
|||
- if @suppress_diff
|
||||
.alert-message.block-message
|
||||
%p
|
||||
%strong Warning! Large commit with more then 200 files changed.
|
||||
%p To prevent performance issue we rejected diff information.
|
||||
%p
|
||||
But if you still want to see diff
|
||||
= link_to "click this link", project_commit_path(@project, @commit.id, :force_show_diff => true), :class => "dark"
|
||||
|
||||
|
||||
%p.cgray
|
||||
Showing #{pluralize(diffs.count, "changed file")}
|
||||
.file_stats
|
||||
= render "commits/diff_head", :diffs => diffs
|
||||
|
||||
- diffs.each_with_index do |diff, i|
|
||||
- next if diff.diff.empty?
|
||||
- file = (@commit.tree / diff.b_path)
|
||||
- file = (@commit.prev_commit.tree / diff.a_path) unless file
|
||||
- next unless file
|
||||
.diff_file
|
||||
.diff_file_header
|
||||
- if diff.deleted_file
|
||||
%strong{:id => "#{diff.a_path}"}= diff.a_path
|
||||
- else
|
||||
= link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do
|
||||
%strong{:id => "#{diff.b_path}"}= diff.b_path
|
||||
%br/
|
||||
.diff_file_content
|
||||
- if file.text?
|
||||
= render "commits/text_file", :diff => diff, :index => i
|
||||
- elsif file.image?
|
||||
.diff_file_content_image
|
||||
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
|
||||
- else
|
||||
%p
|
||||
%center No preview for this file type
|
||||
|
||||
|
||||
- unless @suppress_diff
|
||||
- diffs.each_with_index do |diff, i|
|
||||
- next if diff.diff.empty?
|
||||
- file = (@commit.tree / diff.b_path)
|
||||
- file = (@commit.prev_commit.tree / diff.a_path) unless file
|
||||
- next unless file
|
||||
.diff_file
|
||||
.diff_file_header
|
||||
- if diff.deleted_file
|
||||
%strong{:id => "#{diff.a_path}"}= diff.a_path
|
||||
- else
|
||||
= link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do
|
||||
%strong{:id => "#{diff.b_path}"}= diff.b_path
|
||||
%br/
|
||||
.diff_file_content
|
||||
- if file.text?
|
||||
= render "commits/text_file", :diff => diff, :index => i
|
||||
- elsif file.image?
|
||||
.diff_file_content_image
|
||||
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
|
||||
- else
|
||||
%p
|
||||
%center No preview for this file type
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
%table
|
||||
- too_big = max_lines = diff.diff.lines.count > 1000
|
||||
- if too_big
|
||||
= link_to_function "Diff suppressed. Click to show", "showDiff(this)", :class => "supp_diff_link"
|
||||
|
||||
%table{:class => "#{'hide' if too_big}"}
|
||||
- each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old|
|
||||
%tr.line_holder
|
||||
- if type == "match"
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
%pre.commit_message
|
||||
= commit_msg_with_link_to_issues(@project, @commit.safe_message)
|
||||
%br
|
||||
%p.cgray
|
||||
Showing #{pluralize(@commit.diffs.count, "changed file")}
|
||||
= render "commits/diffs", :diffs => @commit.diffs
|
||||
= render "notes/notes", :tid => @commit.id, :tt => "commit"
|
||||
= render "notes/per_line_form"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue