From a1a01254b903d76e0151b48fa4316add9a6930da Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Wed, 5 Feb 2014 16:21:41 +0200 Subject: [PATCH] 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 | 5 +++++ app/views/projects/compare/show.html.haml | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 02fcb8d255a..696cb7a4ba2 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController @refs_are_same = compare.same @line_notes = [] + if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF] + @diffs = [] + @timeout = true + end + diff_line_count = Commit::diff_line_count(@diffs) @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count) diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index e0c1b01dfbc..9bd49855369 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -22,10 +22,14 @@ - if @diffs.present? = render "projects/commits/diffs", diffs: @diffs, project: @project - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE - .alert.alert-warning - %p - %strong Warning! This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. + .bs-callout.bs-callout-danger + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. %p To preserve performance the line diff is not shown. + - elsif @timeout + .bs-callout.bs-callout-danger + %h4 Diff for this comparison is extremely large. + %p Use command line to browse diff for this comparison. + - else .light-well -- 2.30.9