Commit eded4bfa95320974a0a2f52da2ce0f46974734bb
1 parent
eaa8cd28
Exists in
master
and in
4 other branches
Raise exception and show message to user if repo missing satellite
Showing
3 changed files
with
16 additions
and
3 deletions
Show diff stats
app/controllers/merge_requests_controller.rb
... | ... | @@ -69,6 +69,8 @@ class MergeRequestsController < ProjectResourceController |
69 | 69 | @merge_request.check_if_can_be_merged |
70 | 70 | end |
71 | 71 | render json: {state: @merge_request.human_state} |
72 | + rescue Gitlab::SatelliteNotExistError | |
73 | + render json: {state: :no_satellite} | |
72 | 74 | end |
73 | 75 | |
74 | 76 | def automerge | ... | ... |
app/views/merge_requests/show/_mr_accept.html.haml
... | ... | @@ -23,6 +23,11 @@ |
23 | 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 | 31 | .automerge_widget.cannot_be_merged{style: "display:none"} |
27 | 32 | .alert.alert-info |
28 | 33 | %span | ... | ... |
lib/gitlab/satellite/satellite.rb
1 | 1 | module Gitlab |
2 | + class SatelliteNotExistError < StandardError; end | |
3 | + | |
2 | 4 | module Satellite |
3 | 5 | class Satellite |
4 | 6 | PARKING_BRANCH = "__parking_branch" |
... | ... | @@ -9,8 +11,12 @@ module Gitlab |
9 | 11 | @project = project |
10 | 12 | end |
11 | 13 | |
14 | + def raise_no_satellite | |
15 | + raise SatelliteNotExistError.new("Satellite doesn't exist") | |
16 | + end | |
17 | + | |
12 | 18 | def clear_and_update! |
13 | - raise "Satellite doesn't exist" unless exists? | |
19 | + raise_no_satellite unless exists? | |
14 | 20 | |
15 | 21 | delete_heads! |
16 | 22 | clear_working_dir! |
... | ... | @@ -35,7 +41,7 @@ module Gitlab |
35 | 41 | # * Changes the current directory to the satellite's working dir |
36 | 42 | # * Yields |
37 | 43 | def lock |
38 | - raise "Satellite doesn't exist" unless exists? | |
44 | + raise_no_satellite unless exists? | |
39 | 45 | |
40 | 46 | File.open(lock_file, "w+") do |f| |
41 | 47 | f.flock(File::LOCK_EX) |
... | ... | @@ -55,7 +61,7 @@ module Gitlab |
55 | 61 | end |
56 | 62 | |
57 | 63 | def repo |
58 | - raise "Satellite doesn't exist" unless exists? | |
64 | + raise_no_satellite unless exists? | |
59 | 65 | |
60 | 66 | @repo ||= Grit::Repo.new(path) |
61 | 67 | end | ... | ... |