Commit a1a01254b903d76e0151b48fa4316add9a6930da

Authored by Dmitriy Zaporozhets
1 parent 8f88cbf0

Prevent 500 error on Compare page if diff read timout happens

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/controllers/projects/compare_controller.rb
... ... @@ -16,6 +16,11 @@ class Projects::CompareController &lt; Projects::ApplicationController
16 16 @refs_are_same = compare.same
17 17 @line_notes = []
18 18  
  19 + if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF]
  20 + @diffs = []
  21 + @timeout = true
  22 + end
  23 +
19 24 diff_line_count = Commit::diff_line_count(@diffs)
20 25 @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff]
21 26 @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count)
... ...
app/views/projects/compare/show.html.haml
... ... @@ -22,10 +22,14 @@
22 22 - if @diffs.present?
23 23 = render "projects/commits/diffs", diffs: @diffs, project: @project
24 24 - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
25   - .alert.alert-warning
26   - %p
27   - %strong Warning! This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
  25 + .bs-callout.bs-callout-danger
  26 + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
28 27 %p To preserve performance the line diff is not shown.
  28 + - elsif @timeout
  29 + .bs-callout.bs-callout-danger
  30 + %h4 Diff for this comparison is extremely large.
  31 + %p Use command line to browse diff for this comparison.
  32 +
29 33  
30 34 - else
31 35 .light-well
... ...