Commit 731b6be9c929d9117c322c605a7f53a8319751cd

Authored by randx
1 parent ac525a74

Handle app crash on huge commits

app/contexts/commit_load.rb
... ... @@ -5,7 +5,8 @@ class CommitLoad < BaseContext
5 5 suppress_diff: false,
6 6 line_notes: [],
7 7 notes_count: 0,
8   - note: nil
  8 + note: nil,
  9 + status: :ok
9 10 }
10 11  
11 12 commit = project.commit(params[:id])
... ... @@ -14,11 +15,17 @@ class CommitLoad < BaseContext
14 15 commit = CommitDecorator.decorate(commit)
15 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 18 result[:commit] = commit
19 19 result[:note] = project.build_commit_note(commit)
20 20 result[:line_notes] = line_notes
21 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 29 end
23 30  
24 31 result
... ...
app/controllers/commits_controller.rb
... ... @@ -41,8 +41,9 @@ class CommitsController < ApplicationController
41 41 return git_not_found!
42 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 47 end
47 48  
48 49 def compare
... ...