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,7 +15,7 @@
15 %p 15 %p
16 Diagnostic tool: 16 Diagnostic tool:
17 %pre 17 %pre
18 - bundle exec rake gitlab:app:status RAILS_ENV=production 18 + bundle exec rake gitlab:check RAILS_ENV=production
19 %li 19 %li
20 %p 20 %p
21 Permissions: 21 Permissions:
lib/gitlab/backend/gitolite_config.rb
@@ -6,6 +6,7 @@ module Gitlab @@ -6,6 +6,7 @@ module Gitlab
6 class GitoliteConfig 6 class GitoliteConfig
7 class PullError < StandardError; end 7 class PullError < StandardError; end
8 class PushError < StandardError; end 8 class PushError < StandardError; end
  9 + class BrokenGitolite < StandardError; end
9 10
10 attr_reader :config_tmp_dir, :ga_repo, :conf 11 attr_reader :config_tmp_dir, :ga_repo, :conf
11 12
@@ -72,6 +73,10 @@ module Gitlab @@ -72,6 +73,10 @@ module Gitlab
72 log("Push error -> " + " " + ex.message) 73 log("Push error -> " + " " + ex.message)
73 raise Gitolite::AccessDenied, ex.message 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 rescue Exception => ex 80 rescue Exception => ex
76 log(ex.class.name + " " + ex.message) 81 log(ex.class.name + " " + ex.message)
77 raise Gitolite::AccessDenied.new("gitolite timeout") 82 raise Gitolite::AccessDenied.new("gitolite timeout")
@@ -202,7 +207,15 @@ module Gitlab @@ -202,7 +207,15 @@ module Gitlab
202 system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit 207 system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit
203 raise "Git commit failed." unless [0,1].include? $?.exitstatus 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 Dir.chdir(Rails.root) 219 Dir.chdir(Rails.root)
207 else 220 else
208 raise PushError, "unable to push gitolite-admin repo" 221 raise PushError, "unable to push gitolite-admin repo"