Commit eded4bfa95320974a0a2f52da2ce0f46974734bb

Authored by Dmitriy Zaporozhets
1 parent eaa8cd28

Raise exception and show message to user if repo missing satellite

app/controllers/merge_requests_controller.rb
@@ -69,6 +69,8 @@ class MergeRequestsController < ProjectResourceController @@ -69,6 +69,8 @@ class MergeRequestsController < ProjectResourceController
69 @merge_request.check_if_can_be_merged 69 @merge_request.check_if_can_be_merged
70 end 70 end
71 render json: {state: @merge_request.human_state} 71 render json: {state: @merge_request.human_state}
  72 + rescue Gitlab::SatelliteNotExistError
  73 + render json: {state: :no_satellite}
72 end 74 end
73 75
74 def automerge 76 def automerge
app/views/merge_requests/show/_mr_accept.html.haml
@@ -23,6 +23,11 @@ @@ -23,6 +23,11 @@
23 .clearfix 23 .clearfix
24 24
25 25
  26 + .automerge_widget.no_satellite{style: "display:none"}
  27 + .alert.alert-error
  28 + %span
  29 + %strong This repository does not have satellite. Ask administrator to fix this issue
  30 +
26 .automerge_widget.cannot_be_merged{style: "display:none"} 31 .automerge_widget.cannot_be_merged{style: "display:none"}
27 .alert.alert-info 32 .alert.alert-info
28 %span 33 %span
lib/gitlab/satellite/satellite.rb
1 module Gitlab 1 module Gitlab
  2 + class SatelliteNotExistError < StandardError; end
  3 +
2 module Satellite 4 module Satellite
3 class Satellite 5 class Satellite
4 PARKING_BRANCH = "__parking_branch" 6 PARKING_BRANCH = "__parking_branch"
@@ -9,8 +11,12 @@ module Gitlab @@ -9,8 +11,12 @@ module Gitlab
9 @project = project 11 @project = project
10 end 12 end
11 13
  14 + def raise_no_satellite
  15 + raise SatelliteNotExistError.new("Satellite doesn't exist")
  16 + end
  17 +
12 def clear_and_update! 18 def clear_and_update!
13 - raise "Satellite doesn't exist" unless exists? 19 + raise_no_satellite unless exists?
14 20
15 delete_heads! 21 delete_heads!
16 clear_working_dir! 22 clear_working_dir!
@@ -35,7 +41,7 @@ module Gitlab @@ -35,7 +41,7 @@ module Gitlab
35 # * Changes the current directory to the satellite's working dir 41 # * Changes the current directory to the satellite's working dir
36 # * Yields 42 # * Yields
37 def lock 43 def lock
38 - raise "Satellite doesn't exist" unless exists? 44 + raise_no_satellite unless exists?
39 45
40 File.open(lock_file, "w+") do |f| 46 File.open(lock_file, "w+") do |f|
41 f.flock(File::LOCK_EX) 47 f.flock(File::LOCK_EX)
@@ -55,7 +61,7 @@ module Gitlab @@ -55,7 +61,7 @@ module Gitlab
55 end 61 end
56 62
57 def repo 63 def repo
58 - raise "Satellite doesn't exist" unless exists? 64 + raise_no_satellite unless exists?
59 65
60 @repo ||= Grit::Repo.new(path) 66 @repo ||= Grit::Repo.new(path)
61 end 67 end