Commit e8f39a0a61c4c91b8a5dc016474b6139a79a52e8
1 parent
048117c0
Exists in
master
and in
4 other branches
gitolite -> more exceptions
Showing
1 changed file
with
22 additions
and
4 deletions
Show diff stats
lib/gitlab/backend/gitolite_config.rb
| ... | ... | @@ -4,6 +4,9 @@ require 'fileutils' |
| 4 | 4 | |
| 5 | 5 | module Gitlab |
| 6 | 6 | class GitoliteConfig |
| 7 | + class PullError < StandardError; end | |
| 8 | + class PushError < StandardError; end | |
| 9 | + | |
| 7 | 10 | attr_reader :config_tmp_dir, :ga_repo, :conf |
| 8 | 11 | |
| 9 | 12 | def config_tmp_dir |
| ... | ... | @@ -54,6 +57,14 @@ module Gitlab |
| 54 | 57 | end |
| 55 | 58 | end |
| 56 | 59 | end |
| 60 | + rescue PullError => ex | |
| 61 | + Gitlab::Logger.error("Pull error -> " + ex.message) | |
| 62 | + raise Gitolite::AccessDenied, ex.message | |
| 63 | + | |
| 64 | + rescue PushError => ex | |
| 65 | + Gitlab::Logger.error("Push error -> " + " " + ex.message) | |
| 66 | + raise Gitolite::AccessDenied, ex.message | |
| 67 | + | |
| 57 | 68 | rescue Exception => ex |
| 58 | 69 | Gitlab::Logger.error(ex.class.name + " " + ex.message) |
| 59 | 70 | raise Gitolite::AccessDenied.new("gitolite timeout") |
| ... | ... | @@ -171,14 +182,21 @@ module Gitlab |
| 171 | 182 | def pull tmp_dir |
| 172 | 183 | Dir.mkdir tmp_dir |
| 173 | 184 | `git clone #{Gitlab.config.gitolite_admin_uri} #{tmp_dir}/gitolite` |
| 185 | + | |
| 186 | + unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf')) | |
| 187 | + raise PullError, "unable to clone gitolite-admin repo" | |
| 188 | + end | |
| 174 | 189 | end |
| 175 | 190 | |
| 176 | 191 | def push tmp_dir |
| 177 | 192 | Dir.chdir(File.join(tmp_dir, "gitolite")) |
| 178 | - `git add -A` | |
| 179 | - `git commit -am "GitLab"` | |
| 180 | - `git push` | |
| 181 | - Dir.chdir(Rails.root) | |
| 193 | + system('git add -A') | |
| 194 | + system('git commit -am "GitLab"') | |
| 195 | + if system('git push') | |
| 196 | + Dir.chdir(Rails.root) | |
| 197 | + else | |
| 198 | + raise PushError, "unable to push gitolite-admin repo" | |
| 199 | + end | |
| 182 | 200 | end |
| 183 | 201 | end |
| 184 | 202 | end | ... | ... |