From 01ff084a4df76ba0856a513aca9bdf8f1d550365 Mon Sep 17 00:00:00 2001 From: Boyan Tabakov Date: Wed, 4 Sep 2013 10:33:09 +0300 Subject: Improved large commit handling. Previously, only number of changed files mattered. Now, number of lines to render in the diff are also taken into account. A hard limit is set, above which diffs are not rendered and users are not allowed to override that. This prevents high server resource usage with huge commits. Related to #1745, #2259 In addition, handle large commits for MergeRequests and Compare controllers. Also fixes a bug where diffs are loaded twice, if user goes directly to merge_requests/:id/diffs URL. --- app/contexts/commit_load_context.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/contexts') diff --git a/app/contexts/commit_load_context.rb b/app/contexts/commit_load_context.rb index 2cf5420d62d..2930c5b1668 100644 --- a/app/contexts/commit_load_context.rb +++ b/app/contexts/commit_load_context.rb @@ -20,7 +20,8 @@ class CommitLoadContext < BaseContext result[:notes_count] = project.notes.for_commit_id(commit.id).count begin - result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff] + result[:suppress_diff] = true if commit.diff_suppress? && !params[:force_show_diff] + result[:force_suppress_diff] = commit.diff_force_suppress? rescue Grit::Git::GitTimeout result[:suppress_diff] = true result[:status] = :huge_commit -- cgit v1.2.1