Commit e8f39a0a authored by randx's avatar randx

gitolite -> more exceptions

parent 048117c0
...@@ -4,6 +4,9 @@ require 'fileutils' ...@@ -4,6 +4,9 @@ require 'fileutils'
module Gitlab module Gitlab
class GitoliteConfig class GitoliteConfig
class PullError < StandardError; end
class PushError < StandardError; end
attr_reader :config_tmp_dir, :ga_repo, :conf attr_reader :config_tmp_dir, :ga_repo, :conf
def config_tmp_dir def config_tmp_dir
...@@ -54,6 +57,14 @@ module Gitlab ...@@ -54,6 +57,14 @@ module Gitlab
end end
end end
end end
rescue PullError => ex
Gitlab::Logger.error("Pull error -> " + ex.message)
raise Gitolite::AccessDenied, ex.message
rescue PushError => ex
Gitlab::Logger.error("Push error -> " + " " + ex.message)
raise Gitolite::AccessDenied, ex.message
rescue Exception => ex rescue Exception => ex
Gitlab::Logger.error(ex.class.name + " " + ex.message) Gitlab::Logger.error(ex.class.name + " " + ex.message)
raise Gitolite::AccessDenied.new("gitolite timeout") raise Gitolite::AccessDenied.new("gitolite timeout")
...@@ -171,14 +182,21 @@ module Gitlab ...@@ -171,14 +182,21 @@ module Gitlab
def pull tmp_dir def pull tmp_dir
Dir.mkdir tmp_dir Dir.mkdir tmp_dir
`git clone #{Gitlab.config.gitolite_admin_uri} #{tmp_dir}/gitolite` `git clone #{Gitlab.config.gitolite_admin_uri} #{tmp_dir}/gitolite`
unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf'))
raise PullError, "unable to clone gitolite-admin repo"
end
end end
def push tmp_dir def push tmp_dir
Dir.chdir(File.join(tmp_dir, "gitolite")) Dir.chdir(File.join(tmp_dir, "gitolite"))
`git add -A` system('git add -A')
`git commit -am "GitLab"` system('git commit -am "GitLab"')
`git push` if system('git push')
Dir.chdir(Rails.root) Dir.chdir(Rails.root)
else
raise PushError, "unable to push gitolite-admin repo"
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment