Commit 731b6be9c929d9117c322c605a7f53a8319751cd
1 parent
ac525a74
Exists in
master
and in
4 other branches
Handle app crash on huge commits
Showing
2 changed files
with
12 additions
and
4 deletions
Show diff stats
app/contexts/commit_load.rb
@@ -5,7 +5,8 @@ class CommitLoad < BaseContext | @@ -5,7 +5,8 @@ class CommitLoad < BaseContext | ||
5 | suppress_diff: false, | 5 | suppress_diff: false, |
6 | line_notes: [], | 6 | line_notes: [], |
7 | notes_count: 0, | 7 | notes_count: 0, |
8 | - note: nil | 8 | + note: nil, |
9 | + status: :ok | ||
9 | } | 10 | } |
10 | 11 | ||
11 | commit = project.commit(params[:id]) | 12 | commit = project.commit(params[:id]) |
@@ -14,11 +15,17 @@ class CommitLoad < BaseContext | @@ -14,11 +15,17 @@ class CommitLoad < BaseContext | ||
14 | commit = CommitDecorator.decorate(commit) | 15 | commit = CommitDecorator.decorate(commit) |
15 | line_notes = project.commit_line_notes(commit) | 16 | line_notes = project.commit_line_notes(commit) |
16 | 17 | ||
17 | - result[:suppress_diff] = true if commit.diffs.size > 200 && !params[:force_show_diff] | ||
18 | result[:commit] = commit | 18 | result[:commit] = commit |
19 | result[:note] = project.build_commit_note(commit) | 19 | result[:note] = project.build_commit_note(commit) |
20 | result[:line_notes] = line_notes | 20 | result[:line_notes] = line_notes |
21 | result[:notes_count] = line_notes.count + project.commit_notes(commit).count | 21 | result[:notes_count] = line_notes.count + project.commit_notes(commit).count |
22 | + | ||
23 | + begin | ||
24 | + result[:suppress_diff] = true if commit.diffs.size > 200 && !params[:force_show_diff] | ||
25 | + rescue Grit::Git::GitTimeout | ||
26 | + result[:suppress_diff] = true | ||
27 | + result[:status] = :huge_commit | ||
28 | + end | ||
22 | end | 29 | end |
23 | 30 | ||
24 | result | 31 | result |
app/controllers/commits_controller.rb
@@ -41,8 +41,9 @@ class CommitsController < ApplicationController | @@ -41,8 +41,9 @@ class CommitsController < ApplicationController | ||
41 | return git_not_found! | 41 | return git_not_found! |
42 | end | 42 | end |
43 | 43 | ||
44 | - rescue Grit::Git::GitTimeout | ||
45 | - render "huge_commit" | 44 | + if result[:status] == :huge_commit |
45 | + render "huge_commit" and return | ||
46 | + end | ||
46 | end | 47 | end |
47 | 48 | ||
48 | def compare | 49 | def compare |