Commit 569a88a456a5f01fbef6f5280b6982c3db8e2a72

Authored by Dmitriy Zaporozhets
1 parent 5c3fdfaa

raise exception if gitolite is broken

app/views/errors/gitolite.html.haml
... ... @@ -15,7 +15,7 @@
15 15 %p
16 16 Diagnostic tool:
17 17 %pre
18   - bundle exec rake gitlab:app:status RAILS_ENV=production
  18 + bundle exec rake gitlab:check RAILS_ENV=production
19 19 %li
20 20 %p
21 21 Permissions:
... ...
lib/gitlab/backend/gitolite_config.rb
... ... @@ -6,6 +6,7 @@ module Gitlab
6 6 class GitoliteConfig
7 7 class PullError < StandardError; end
8 8 class PushError < StandardError; end
  9 + class BrokenGitolite < StandardError; end
9 10  
10 11 attr_reader :config_tmp_dir, :ga_repo, :conf
11 12  
... ... @@ -72,6 +73,10 @@ module Gitlab
72 73 log("Push error -> " + " " + ex.message)
73 74 raise Gitolite::AccessDenied, ex.message
74 75  
  76 + rescue BrokenGitolite => ex
  77 + log("Gitolite error -> " + " " + ex.message)
  78 + raise Gitolite::AccessDenied, ex.message
  79 +
75 80 rescue Exception => ex
76 81 log(ex.class.name + " " + ex.message)
77 82 raise Gitolite::AccessDenied.new("gitolite timeout")
... ... @@ -202,7 +207,15 @@ module Gitlab
202 207 system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit
203 208 raise "Git commit failed." unless [0,1].include? $?.exitstatus
204 209  
205   - if system('git push')
  210 + stdin, stdout, stderr = Open3.popen3('git push')
  211 + push_output = stderr.read
  212 + push_status = $?.to_i
  213 +
  214 + if push_output =~ /remote\: FATAL/
  215 + raise BrokenGitolite, push_output
  216 + end
  217 +
  218 + if push_status.zero?
206 219 Dir.chdir(Rails.root)
207 220 else
208 221 raise PushError, "unable to push gitolite-admin repo"
... ...