diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 6ab353d22219d1f8dfc0fb151be0cb998d331df1..e15e1be2c6d5e97c2d997fd0de0b0c1c16b8c107 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -74,9 +74,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController @merge_request.source_branch ) + @compare_failed = false @commits = compare_action.commits - @commits.map! { |commit| Commit.new(commit) } - @commit = @commits.first + + if @commits + @commits.map! { |commit| Commit.new(commit) } + @commit = @commits.first + else + # false value because failed to get commits from satellite + @commits = [] + @compare_failed = true + end @diffs = compare_action.diffs @merge_request.title = @merge_request.source_branch.titleize.humanize diff --git a/app/views/projects/merge_requests/_new_compare.html.haml b/app/views/projects/merge_requests/_new_compare.html.haml index a8b774a3cd1ce58bcc497caaf951cb782ed0182b..f8f14a71a11acf04c3c7beef317909722e330a23 100644 --- a/app/views/projects/merge_requests/_new_compare.html.haml +++ b/app/views/projects/merge_requests/_new_compare.html.haml @@ -33,18 +33,23 @@ %div= msg - if @merge_request.source_branch.present? && @merge_request.target_branch.present? - .light-well - %center - %h4 - There isn't anything to merge. - %p.slead - - if @merge_request.source_branch == @merge_request.target_branch - You'll need to use different branch names to get a valid comparison. - - else - %span.label-branch #{@merge_request.source_branch} - and - %span.label-branch #{@merge_request.target_branch} - are the same. + - if @compare_failed + .alert.alert-danger + %h4 Compare failed + %p We can't compare selected branches. It may be because of huge diff or satellite timeout. Please try again or select different branches. + - else + .light-well + %center + %h4 + There isn't anything to merge. + %p.slead + - if @merge_request.source_branch == @merge_request.target_branch + You'll need to use different branch names to get a valid comparison. + - else + %span.label-branch #{@merge_request.source_branch} + and + %span.label-branch #{@merge_request.target_branch} + are the same. %hr