Commit 54a24608a29d113f0c607027cddd8b6947c6a55c
1 parent
cfe89832
Exists in
master
and in
4 other branches
Remove chdir inside runtime. Improved gitolite shell commands
Showing
3 changed files
with
39 additions
and
14 deletions
Show diff stats
Gemfile
@@ -127,6 +127,9 @@ group :development do | @@ -127,6 +127,9 @@ group :development do | ||
127 | 127 | ||
128 | # Docs generator | 128 | # Docs generator |
129 | gem "sdoc" | 129 | gem "sdoc" |
130 | + | ||
131 | + # thin instead webrick | ||
132 | + gem 'thin' | ||
130 | end | 133 | end |
131 | 134 | ||
132 | group :development, :test do | 135 | group :development, :test do |
Gemfile.lock
@@ -144,6 +144,7 @@ GEM | @@ -144,6 +144,7 @@ GEM | ||
144 | colorize (0.5.8) | 144 | colorize (0.5.8) |
145 | connection_pool (1.0.0) | 145 | connection_pool (1.0.0) |
146 | crack (0.3.1) | 146 | crack (0.3.1) |
147 | + daemons (1.1.9) | ||
147 | devise (2.1.2) | 148 | devise (2.1.2) |
148 | bcrypt-ruby (~> 3.0) | 149 | bcrypt-ruby (~> 3.0) |
149 | orm_adapter (~> 0.1) | 150 | orm_adapter (~> 0.1) |
@@ -436,6 +437,10 @@ GEM | @@ -436,6 +437,10 @@ GEM | ||
436 | test_after_commit (0.0.1) | 437 | test_after_commit (0.0.1) |
437 | therubyracer (0.10.2) | 438 | therubyracer (0.10.2) |
438 | libv8 (~> 3.3.10) | 439 | libv8 (~> 3.3.10) |
440 | + thin (1.5.0) | ||
441 | + daemons (>= 1.0.9) | ||
442 | + eventmachine (>= 0.12.6) | ||
443 | + rack (>= 1.0.0) | ||
439 | thor (0.16.0) | 444 | thor (0.16.0) |
440 | tilt (1.3.3) | 445 | tilt (1.3.3) |
441 | timers (1.0.2) | 446 | timers (1.0.2) |
@@ -542,6 +547,7 @@ DEPENDENCIES | @@ -542,6 +547,7 @@ DEPENDENCIES | ||
542 | stamp | 547 | stamp |
543 | test_after_commit | 548 | test_after_commit |
544 | therubyracer | 549 | therubyracer |
550 | + thin | ||
545 | uglifier (~> 1.3.0) | 551 | uglifier (~> 1.3.0) |
546 | unicorn (~> 4.4.0) | 552 | unicorn (~> 4.4.0) |
547 | webmock | 553 | webmock |
lib/gitlab/backend/gitolite_config.rb
@@ -77,9 +77,9 @@ module Gitlab | @@ -77,9 +77,9 @@ module Gitlab | ||
77 | log("Gitolite error -> " + " " + ex.message) | 77 | log("Gitolite error -> " + " " + ex.message) |
78 | raise Gitolite::AccessDenied, ex.message | 78 | raise Gitolite::AccessDenied, ex.message |
79 | 79 | ||
80 | - rescue Exception => ex | ||
81 | - log(ex.class.name + " " + ex.message) | ||
82 | - raise Gitolite::AccessDenied.new("gitolite timeout") | 80 | + #rescue Exception => ex |
81 | + #log(ex.class.name + " " + ex.message) | ||
82 | + #raise Gitolite::AccessDenied.new("gitolite timeout") | ||
83 | end | 83 | end |
84 | 84 | ||
85 | def log message | 85 | def log message |
@@ -202,25 +202,41 @@ module Gitlab | @@ -202,25 +202,41 @@ module Gitlab | ||
202 | end | 202 | end |
203 | 203 | ||
204 | def push tmp_dir | 204 | def push tmp_dir |
205 | - Dir.chdir(File.join(tmp_dir, "gitolite")) | ||
206 | - raise "Git add failed." unless system('git add -A') | ||
207 | - system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit | ||
208 | - raise "Git commit failed." unless [0,1].include? $?.exitstatus | 205 | + output, status = popen('git add -A') |
206 | + raise "Git add failed." unless status.zero? | ||
209 | 207 | ||
210 | - stdin, stdout, stderr = Open3.popen3('git push') | ||
211 | - push_output = stderr.read | ||
212 | - push_status = $?.to_i | 208 | + # git commit returns 0 on success, and 1 if there is nothing to commit |
209 | + output, status = popen('git commit -m "GitLab"') | ||
210 | + raise "Git add failed." unless [0,1].include?(status) | ||
213 | 211 | ||
214 | - if push_output =~ /remote\: FATAL/ | ||
215 | - raise BrokenGitolite, push_output | 212 | + output, status = popen('git push') |
213 | + | ||
214 | + if output =~ /remote\: FATAL/ | ||
215 | + raise BrokenGitolite, output | ||
216 | end | 216 | end |
217 | 217 | ||
218 | - if push_status.zero? | ||
219 | - Dir.chdir(Rails.root) | 218 | + if status.zero? || output =~ /Everything up\-to\-date/ |
219 | + return true | ||
220 | else | 220 | else |
221 | raise PushError, "unable to push gitolite-admin repo" | 221 | raise PushError, "unable to push gitolite-admin repo" |
222 | end | 222 | end |
223 | end | 223 | end |
224 | + | ||
225 | + def popen(cmd) | ||
226 | + path = File.join(config_tmp_dir,'gitolite') | ||
227 | + vars = { "PWD" => path } | ||
228 | + options = { :chdir => path } | ||
229 | + | ||
230 | + @cmd_output = "" | ||
231 | + @cmd_status = 0 | ||
232 | + Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| | ||
233 | + @cmd_status = wait_thr.value.exitstatus | ||
234 | + @cmd_output << stdout.read | ||
235 | + @cmd_output << stderr.read | ||
236 | + end | ||
237 | + | ||
238 | + return @cmd_output, @cmd_status | ||
239 | + end | ||
224 | end | 240 | end |
225 | end | 241 | end |
226 | 242 |