diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-05 23:09:26 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-05 23:09:26 +0200 |
commit | eded4bfa95320974a0a2f52da2ce0f46974734bb (patch) | |
tree | ccdbd1a6d28859bd037f7520870d50144988adc3 | |
parent | eaa8cd28d07a1017b3e2abfc43d008daca962343 (diff) | |
download | gitlab-ce-eded4bfa95320974a0a2f52da2ce0f46974734bb.tar.gz |
Raise exception and show message to user if repo missing satellite
-rw-r--r-- | app/controllers/merge_requests_controller.rb | 2 | ||||
-rw-r--r-- | app/views/merge_requests/show/_mr_accept.html.haml | 5 | ||||
-rw-r--r-- | lib/gitlab/satellite/satellite.rb | 12 |
3 files changed, 16 insertions, 3 deletions
diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index d2d92e60585..6ead406aac5 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -69,6 +69,8 @@ class MergeRequestsController < ProjectResourceController @merge_request.check_if_can_be_merged end render json: {state: @merge_request.human_state} + rescue Gitlab::SatelliteNotExistError + render json: {state: :no_satellite} end def automerge diff --git a/app/views/merge_requests/show/_mr_accept.html.haml b/app/views/merge_requests/show/_mr_accept.html.haml index 81ce987c183..128ffe76782 100644 --- a/app/views/merge_requests/show/_mr_accept.html.haml +++ b/app/views/merge_requests/show/_mr_accept.html.haml @@ -23,6 +23,11 @@ .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"} .alert.alert-info %span diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 784b146b98a..a0abf1918ca 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -1,4 +1,6 @@ module Gitlab + class SatelliteNotExistError < StandardError; end + module Satellite class Satellite PARKING_BRANCH = "__parking_branch" @@ -9,8 +11,12 @@ module Gitlab @project = project end + def raise_no_satellite + raise SatelliteNotExistError.new("Satellite doesn't exist") + end + def clear_and_update! - raise "Satellite doesn't exist" unless exists? + raise_no_satellite unless exists? delete_heads! clear_working_dir! @@ -35,7 +41,7 @@ module Gitlab # * Changes the current directory to the satellite's working dir # * Yields def lock - raise "Satellite doesn't exist" unless exists? + raise_no_satellite unless exists? File.open(lock_file, "w+") do |f| f.flock(File::LOCK_EX) @@ -55,7 +61,7 @@ module Gitlab end def repo - raise "Satellite doesn't exist" unless exists? + raise_no_satellite unless exists? @repo ||= Grit::Repo.new(path) end |