Commit 86676476e6a8a23786ccbc927ad24140a47e96af
1 parent
17a88bb6
Exists in
master
and in
4 other branches
Handling big commits & big diff
Showing
7 changed files
with
85 additions
and
53 deletions
Show diff stats
app/assets/javascripts/application.js
@@ -74,3 +74,8 @@ function resetMenu() { | @@ -74,3 +74,8 @@ function resetMenu() { | ||
74 | function slugify(text) { | 74 | function slugify(text) { |
75 | return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); | 75 | return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); |
76 | } | 76 | } |
77 | + | ||
78 | +function showDiff(link) { | ||
79 | + $(link).next('table').show(); | ||
80 | + $(link).remove(); | ||
81 | +} |
app/assets/stylesheets/common.scss
@@ -17,9 +17,15 @@ a { | @@ -17,9 +17,15 @@ a { | ||
17 | &.lined { | 17 | &.lined { |
18 | text-decoration:underlined; | 18 | text-decoration:underlined; |
19 | } | 19 | } |
20 | + &.supp_diff_link { | ||
21 | + text-align:center; | ||
22 | + padding:20px 0; | ||
23 | + background:#f1f1f1; | ||
24 | + width:100%; | ||
25 | + float:left; | ||
26 | + } | ||
20 | } | 27 | } |
21 | 28 | ||
22 | - | ||
23 | .btn { | 29 | .btn { |
24 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f1f1f1), color-stop(25%, #f1f1f1), to(#e6e6e6)); | 30 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f1f1f1), color-stop(25%, #f1f1f1), to(#e6e6e6)); |
25 | background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 25%, #e6e6e6); | 31 | background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 25%, #e6e6e6); |
app/controllers/commits_controller.rb
@@ -34,6 +34,10 @@ class CommitsController < ApplicationController | @@ -34,6 +34,10 @@ class CommitsController < ApplicationController | ||
34 | @line_notes = project.commit_line_notes(@commit) | 34 | @line_notes = project.commit_line_notes(@commit) |
35 | 35 | ||
36 | @notes_count = @line_notes.count + project.commit_notes(@commit).count | 36 | @notes_count = @line_notes.count + project.commit_notes(@commit).count |
37 | + | ||
38 | + if @commit.diffs.size > 200 && !params[:force_show_diff] | ||
39 | + @suppress_diff = true | ||
40 | + end | ||
37 | end | 41 | end |
38 | 42 | ||
39 | def compare | 43 | def compare |
app/views/commits/_diffs.html.haml
1 | +- if @suppress_diff | ||
2 | + .alert-message.block-message | ||
3 | + %p | ||
4 | + %strong Warning! Large commit with more then 200 files changed. | ||
5 | + %p To prevent performance issue we rejected diff information. | ||
6 | + %p | ||
7 | + But if you still want to see diff | ||
8 | + = link_to "click this link", project_commit_path(@project, @commit.id, :force_show_diff => true), :class => "dark" | ||
9 | + | ||
10 | + | ||
11 | +%p.cgray | ||
12 | + Showing #{pluralize(diffs.count, "changed file")} | ||
1 | .file_stats | 13 | .file_stats |
2 | = render "commits/diff_head", :diffs => diffs | 14 | = render "commits/diff_head", :diffs => diffs |
3 | - | ||
4 | -- diffs.each_with_index do |diff, i| | ||
5 | - - next if diff.diff.empty? | ||
6 | - - file = (@commit.tree / diff.b_path) | ||
7 | - - file = (@commit.prev_commit.tree / diff.a_path) unless file | ||
8 | - - next unless file | ||
9 | - .diff_file | ||
10 | - .diff_file_header | ||
11 | - - if diff.deleted_file | ||
12 | - %strong{:id => "#{diff.a_path}"}= diff.a_path | ||
13 | - - else | ||
14 | - = link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do | ||
15 | - %strong{:id => "#{diff.b_path}"}= diff.b_path | ||
16 | - %br/ | ||
17 | - .diff_file_content | ||
18 | - - if file.text? | ||
19 | - = render "commits/text_file", :diff => diff, :index => i | ||
20 | - - elsif file.image? | ||
21 | - .diff_file_content_image | ||
22 | - %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | ||
23 | - - else | ||
24 | - %p | ||
25 | - %center No preview for this file type | 15 | + |
16 | + | ||
17 | +- unless @suppress_diff | ||
18 | + - diffs.each_with_index do |diff, i| | ||
19 | + - next if diff.diff.empty? | ||
20 | + - file = (@commit.tree / diff.b_path) | ||
21 | + - file = (@commit.prev_commit.tree / diff.a_path) unless file | ||
22 | + - next unless file | ||
23 | + .diff_file | ||
24 | + .diff_file_header | ||
25 | + - if diff.deleted_file | ||
26 | + %strong{:id => "#{diff.a_path}"}= diff.a_path | ||
27 | + - else | ||
28 | + = link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do | ||
29 | + %strong{:id => "#{diff.b_path}"}= diff.b_path | ||
30 | + %br/ | ||
31 | + .diff_file_content | ||
32 | + - if file.text? | ||
33 | + = render "commits/text_file", :diff => diff, :index => i | ||
34 | + - elsif file.image? | ||
35 | + .diff_file_content_image | ||
36 | + %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | ||
37 | + - else | ||
38 | + %p | ||
39 | + %center No preview for this file type | ||
26 | 40 |
app/views/commits/_text_file.html.haml
1 | -%table | 1 | +- too_big = max_lines = diff.diff.lines.count > 1000 |
2 | +- if too_big | ||
3 | + = link_to_function "Diff suppressed. Click to show", "showDiff(this)", :class => "supp_diff_link" | ||
4 | + | ||
5 | +%table{:class => "#{'hide' if too_big}"} | ||
2 | - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| | 6 | - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| |
3 | %tr.line_holder | 7 | %tr.line_holder |
4 | - if type == "match" | 8 | - if type == "match" |
app/views/commits/show.html.haml
@@ -21,8 +21,6 @@ | @@ -21,8 +21,6 @@ | ||
21 | %pre.commit_message | 21 | %pre.commit_message |
22 | = commit_msg_with_link_to_issues(@project, @commit.safe_message) | 22 | = commit_msg_with_link_to_issues(@project, @commit.safe_message) |
23 | %br | 23 | %br |
24 | -%p.cgray | ||
25 | - Showing #{pluralize(@commit.diffs.count, "changed file")} | ||
26 | = render "commits/diffs", :diffs => @commit.diffs | 24 | = render "commits/diffs", :diffs => @commit.diffs |
27 | = render "notes/notes", :tid => @commit.id, :tt => "commit" | 25 | = render "notes/notes", :tid => @commit.id, :tt => "commit" |
28 | = render "notes/per_line_form" | 26 | = render "notes/per_line_form" |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20120323221339) do | 14 | +ActiveRecord::Schema.define(:version => 20120405211750) do |
15 | 15 | ||
16 | create_table "events", :force => true do |t| | 16 | create_table "events", :force => true do |t| |
17 | t.string "target_type" | 17 | t.string "target_type" |
@@ -30,8 +30,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -30,8 +30,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
30 | t.integer "assignee_id" | 30 | t.integer "assignee_id" |
31 | t.integer "author_id" | 31 | t.integer "author_id" |
32 | t.integer "project_id" | 32 | t.integer "project_id" |
33 | - t.datetime "created_at" | ||
34 | - t.datetime "updated_at" | 33 | + t.datetime "created_at", :null => false |
34 | + t.datetime "updated_at", :null => false | ||
35 | t.boolean "closed", :default => false, :null => false | 35 | t.boolean "closed", :default => false, :null => false |
36 | t.integer "position", :default => 0 | 36 | t.integer "position", :default => 0 |
37 | t.boolean "critical", :default => false, :null => false | 37 | t.boolean "critical", :default => false, :null => false |
@@ -43,8 +43,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -43,8 +43,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
43 | 43 | ||
44 | create_table "keys", :force => true do |t| | 44 | create_table "keys", :force => true do |t| |
45 | t.integer "user_id" | 45 | t.integer "user_id" |
46 | - t.datetime "created_at" | ||
47 | - t.datetime "updated_at" | 46 | + t.datetime "created_at", :null => false |
47 | + t.datetime "updated_at", :null => false | ||
48 | t.text "key" | 48 | t.text "key" |
49 | t.string "title" | 49 | t.string "title" |
50 | t.string "identifier" | 50 | t.string "identifier" |
@@ -52,18 +52,19 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -52,18 +52,19 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
52 | end | 52 | end |
53 | 53 | ||
54 | create_table "merge_requests", :force => true do |t| | 54 | create_table "merge_requests", :force => true do |t| |
55 | - t.string "target_branch", :null => false | ||
56 | - t.string "source_branch", :null => false | ||
57 | - t.integer "project_id", :null => false | 55 | + t.string "target_branch", :null => false |
56 | + t.string "source_branch", :null => false | ||
57 | + t.integer "project_id", :null => false | ||
58 | t.integer "author_id" | 58 | t.integer "author_id" |
59 | t.integer "assignee_id" | 59 | t.integer "assignee_id" |
60 | t.string "title" | 60 | t.string "title" |
61 | - t.boolean "closed", :default => false, :null => false | ||
62 | - t.datetime "created_at" | ||
63 | - t.datetime "updated_at" | ||
64 | - t.text "st_commits" | ||
65 | - t.text "st_diffs" | ||
66 | - t.boolean "merged", :default => false, :null => false | 61 | + t.boolean "closed", :default => false, :null => false |
62 | + t.datetime "created_at", :null => false | ||
63 | + t.datetime "updated_at", :null => false | ||
64 | + t.text "st_commits", :limit => 2147483647 | ||
65 | + t.text "st_diffs", :limit => 2147483647 | ||
66 | + t.boolean "merged", :default => false, :null => false | ||
67 | + t.boolean "auto_merge", :default => true, :null => false | ||
67 | end | 68 | end |
68 | 69 | ||
69 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" | 70 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" |
@@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
73 | t.string "noteable_id" | 74 | t.string "noteable_id" |
74 | t.string "noteable_type" | 75 | t.string "noteable_type" |
75 | t.integer "author_id" | 76 | t.integer "author_id" |
76 | - t.datetime "created_at" | ||
77 | - t.datetime "updated_at" | 77 | + t.datetime "created_at", :null => false |
78 | + t.datetime "updated_at", :null => false | ||
78 | t.integer "project_id" | 79 | t.integer "project_id" |
79 | t.string "attachment" | 80 | t.string "attachment" |
80 | t.string "line_code" | 81 | t.string "line_code" |
@@ -87,8 +88,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -87,8 +88,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
87 | t.string "name" | 88 | t.string "name" |
88 | t.string "path" | 89 | t.string "path" |
89 | t.text "description" | 90 | t.text "description" |
90 | - t.datetime "created_at" | ||
91 | - t.datetime "updated_at" | 91 | + t.datetime "created_at", :null => false |
92 | + t.datetime "updated_at", :null => false | ||
92 | t.boolean "private_flag", :default => true, :null => false | 93 | t.boolean "private_flag", :default => true, :null => false |
93 | t.string "code" | 94 | t.string "code" |
94 | t.integer "owner_id" | 95 | t.integer "owner_id" |
@@ -111,8 +112,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -111,8 +112,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
111 | t.text "content" | 112 | t.text "content" |
112 | t.integer "author_id", :null => false | 113 | t.integer "author_id", :null => false |
113 | t.integer "project_id", :null => false | 114 | t.integer "project_id", :null => false |
114 | - t.datetime "created_at" | ||
115 | - t.datetime "updated_at" | 115 | + t.datetime "created_at", :null => false |
116 | + t.datetime "updated_at", :null => false | ||
116 | t.string "file_name" | 117 | t.string "file_name" |
117 | t.datetime "expires_at" | 118 | t.datetime "expires_at" |
118 | end | 119 | end |
@@ -145,8 +146,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -145,8 +146,8 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
145 | t.datetime "last_sign_in_at" | 146 | t.datetime "last_sign_in_at" |
146 | t.string "current_sign_in_ip" | 147 | t.string "current_sign_in_ip" |
147 | t.string "last_sign_in_ip" | 148 | t.string "last_sign_in_ip" |
148 | - t.datetime "created_at" | ||
149 | - t.datetime "updated_at" | 149 | + t.datetime "created_at", :null => false |
150 | + t.datetime "updated_at", :null => false | ||
150 | t.string "name" | 151 | t.string "name" |
151 | t.boolean "admin", :default => false, :null => false | 152 | t.boolean "admin", :default => false, :null => false |
152 | t.integer "projects_limit", :default => 10 | 153 | t.integer "projects_limit", :default => 10 |
@@ -165,16 +166,16 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | @@ -165,16 +166,16 @@ ActiveRecord::Schema.define(:version => 20120323221339) do | ||
165 | create_table "users_projects", :force => true do |t| | 166 | create_table "users_projects", :force => true do |t| |
166 | t.integer "user_id", :null => false | 167 | t.integer "user_id", :null => false |
167 | t.integer "project_id", :null => false | 168 | t.integer "project_id", :null => false |
168 | - t.datetime "created_at" | ||
169 | - t.datetime "updated_at" | 169 | + t.datetime "created_at", :null => false |
170 | + t.datetime "updated_at", :null => false | ||
170 | t.integer "project_access", :default => 0, :null => false | 171 | t.integer "project_access", :default => 0, :null => false |
171 | end | 172 | end |
172 | 173 | ||
173 | create_table "web_hooks", :force => true do |t| | 174 | create_table "web_hooks", :force => true do |t| |
174 | t.string "url" | 175 | t.string "url" |
175 | t.integer "project_id" | 176 | t.integer "project_id" |
176 | - t.datetime "created_at" | ||
177 | - t.datetime "updated_at" | 177 | + t.datetime "created_at", :null => false |
178 | + t.datetime "updated_at", :null => false | ||
178 | end | 179 | end |
179 | 180 | ||
180 | create_table "wikis", :force => true do |t| | 181 | create_table "wikis", :force => true do |t| |