Commit 6d0dcb66 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Reduce max commit diff size. Added Commit::DIFF_SAFE_SIZE

parent 1ea0dd0f
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
.underlined { border-bottom: 1px solid #CCC; } .underlined { border-bottom: 1px solid #CCC; }
.no-borders { border:none; } .no-borders { border:none; }
.vlink { color: $link_color !important; } .vlink { color: $link_color !important; }
.underlined_link { text-decoration: underline; }
.borders { border: 1px solid #ccc; @include shade; } .borders { border: 1px solid #ccc; @include shade; }
.hint { font-style: italic; color: #999; } .hint { font-style: italic; color: #999; }
......
...@@ -21,7 +21,7 @@ class CommitLoadContext < BaseContext ...@@ -21,7 +21,7 @@ class CommitLoadContext < BaseContext
result[:notes_count] = line_notes.count + project.commit_notes(commit).count result[:notes_count] = line_notes.count + project.commit_notes(commit).count
begin 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 rescue Grit::Git::GitTimeout
result[:suppress_diff] = true result[:suppress_diff] = true
result[:status] = :huge_commit result[:status] = :huge_commit
......
...@@ -4,6 +4,11 @@ class Commit ...@@ -4,6 +4,11 @@ class Commit
include StaticModel include StaticModel
extend ActiveModel::Naming 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 attr_accessor :commit, :head, :refs
delegate :message, :authored_date, :committed_date, :parents, :sha, delegate :message, :authored_date, :committed_date, :parents, :sha,
......
- if @suppress_diff - if @suppress_diff
.alert-message.block-message .alert-message.block-message
%p %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 To prevent performance issue we rejected diff information.
%p %p
But if you still want to see diff 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 %p.cgray
Showing #{pluralize(diffs.count, "changed file")} Showing #{pluralize(diffs.count, "changed file")}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment