Raise exception and show message to user if repo missing satellite
This commit is contained in:
parent
eaa8cd28d0
commit
eded4bfa95
3 changed files with 16 additions and 3 deletions
|
@ -69,6 +69,8 @@ class MergeRequestsController < ProjectResourceController
|
||||||
@merge_request.check_if_can_be_merged
|
@merge_request.check_if_can_be_merged
|
||||||
end
|
end
|
||||||
render json: {state: @merge_request.human_state}
|
render json: {state: @merge_request.human_state}
|
||||||
|
rescue Gitlab::SatelliteNotExistError
|
||||||
|
render json: {state: :no_satellite}
|
||||||
end
|
end
|
||||||
|
|
||||||
def automerge
|
def automerge
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
.clearfix
|
.clearfix
|
||||||
|
|
||||||
|
|
||||||
|
.automerge_widget.no_satellite{style: "display:none"}
|
||||||
|
.alert.alert-error
|
||||||
|
%span
|
||||||
|
%strong This repository does not have satellite. Ask administrator to fix this issue
|
||||||
|
|
||||||
.automerge_widget.cannot_be_merged{style: "display:none"}
|
.automerge_widget.cannot_be_merged{style: "display:none"}
|
||||||
.alert.alert-info
|
.alert.alert-info
|
||||||
%span
|
%span
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
|
class SatelliteNotExistError < StandardError; end
|
||||||
|
|
||||||
module Satellite
|
module Satellite
|
||||||
class Satellite
|
class Satellite
|
||||||
PARKING_BRANCH = "__parking_branch"
|
PARKING_BRANCH = "__parking_branch"
|
||||||
|
@ -9,8 +11,12 @@ module Gitlab
|
||||||
@project = project
|
@project = project
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def raise_no_satellite
|
||||||
|
raise SatelliteNotExistError.new("Satellite doesn't exist")
|
||||||
|
end
|
||||||
|
|
||||||
def clear_and_update!
|
def clear_and_update!
|
||||||
raise "Satellite doesn't exist" unless exists?
|
raise_no_satellite unless exists?
|
||||||
|
|
||||||
delete_heads!
|
delete_heads!
|
||||||
clear_working_dir!
|
clear_working_dir!
|
||||||
|
@ -35,7 +41,7 @@ module Gitlab
|
||||||
# * Changes the current directory to the satellite's working dir
|
# * Changes the current directory to the satellite's working dir
|
||||||
# * Yields
|
# * Yields
|
||||||
def lock
|
def lock
|
||||||
raise "Satellite doesn't exist" unless exists?
|
raise_no_satellite unless exists?
|
||||||
|
|
||||||
File.open(lock_file, "w+") do |f|
|
File.open(lock_file, "w+") do |f|
|
||||||
f.flock(File::LOCK_EX)
|
f.flock(File::LOCK_EX)
|
||||||
|
@ -55,7 +61,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def repo
|
def repo
|
||||||
raise "Satellite doesn't exist" unless exists?
|
raise_no_satellite unless exists?
|
||||||
|
|
||||||
@repo ||= Grit::Repo.new(path)
|
@repo ||= Grit::Repo.new(path)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue