summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-10-25 12:16:14 +0300
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-10-25 12:16:14 +0300
commit6d0dcb6614fc0743d50ffe68bf61c2c50728c1d6 (patch)
tree131346c6348cf7d509e11fe1de21626a1912fa89
parent1ea0dd0ffc37232d27f4fa1350af6ebb3b5439f2 (diff)
downloadgitlab-ce-6d0dcb6614fc0743d50ffe68bf61c2c50728c1d6.tar.gz
Reduce max commit diff size. Added Commit::DIFF_SAFE_SIZE
-rw-r--r--app/assets/stylesheets/gitlab_bootstrap/common.scss1
-rw-r--r--app/contexts/commit_load_context.rb2
-rw-r--r--app/models/commit.rb5
-rw-r--r--app/views/commits/_diffs.html.haml8
4 files changed, 11 insertions, 5 deletions
diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss
index 85bb5b228df..eb3bd06f5be 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/common.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss
@@ -26,6 +26,7 @@
.underlined { border-bottom: 1px solid #CCC; }
.no-borders { border:none; }
.vlink { color: $link_color !important; }
+.underlined_link { text-decoration: underline; }
.borders { border: 1px solid #ccc; @include shade; }
.hint { font-style: italic; color: #999; }
diff --git a/app/contexts/commit_load_context.rb b/app/contexts/commit_load_context.rb
index b3548ed858e..e43e5a07805 100644
--- a/app/contexts/commit_load_context.rb
+++ b/app/contexts/commit_load_context.rb
@@ -21,7 +21,7 @@ class CommitLoadContext < BaseContext
result[:notes_count] = line_notes.count + project.commit_notes(commit).count
begin
- result[:suppress_diff] = true if commit.diffs.size > 200 && !params[:force_show_diff]
+ result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff]
rescue Grit::Git::GitTimeout
result[:suppress_diff] = true
result[:status] = :huge_commit
diff --git a/app/models/commit.rb b/app/models/commit.rb
index a070e830680..e6a87dd9217 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -4,6 +4,11 @@ class Commit
include StaticModel
extend ActiveModel::Naming
+ # Safe amount of files with diffs in one commit to render
+ # Used to prevent 500 error on huge commits by suppressing diff
+ #
+ DIFF_SAFE_SIZE = 100
+
attr_accessor :commit, :head, :refs
delegate :message, :authored_date, :committed_date, :parents, :sha,
diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml
index 026fe27e075..70fff53c1d1 100644
--- a/app/views/commits/_diffs.html.haml
+++ b/app/views/commits/_diffs.html.haml
@@ -1,11 +1,11 @@
- if @suppress_diff
.alert-message.block-message
%p
- %strong Warning! Large commit with more then 200 files changed.
+ %strong Warning! Large commit with more then #{Commit::DIFF_SAFE_SIZE} 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, force_show_diff: true), class: "dark"
+ = link_to "click this link", project_commit_path(@project, @commit, force_show_diff: true), class: "underlined_link"
%p.cgray
Showing #{pluralize(diffs.count, "changed file")}
@@ -35,10 +35,10 @@
- if file.text?
= render "commits/text_file", diff: diff, index: i
- elsif file.image?
- - if diff.renamed_file || diff.new_file || diff.deleted_file
+ - if diff.renamed_file || diff.new_file || diff.deleted_file
.diff_file_content_image
%img{class: image_diff_class(diff), src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
- - else
+ - else
- old_file = (@commit.prev_commit.tree / diff.old_path)
.diff_file_content_image.img_compared
%img{class: "diff_image_removed", src: "data:#{file.mime_type};base64,#{Base64.encode64(old_file.data)}"}