Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-19 15:56:55 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-19 15:56:55 +0400
commit54a24608a29d113f0c607027cddd8b6947c6a55c (patch)
treea85f917e0386bf6b83f97622167339cffd519785 /lib
parentcfe89832722c50e798d73ac43d6e0ae7d7fb78e9 (diff)
Remove chdir inside runtime. Improved gitolite shell commands
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/backend/gitolite_config.rb44
1 files changed, 30 insertions, 14 deletions
diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb
index 720ef8d236b..35e87c09e09 100644
--- a/lib/gitlab/backend/gitolite_config.rb
+++ b/lib/gitlab/backend/gitolite_config.rb
@@ -77,9 +77,9 @@ module Gitlab
log("Gitolite error -> " + " " + ex.message)
raise Gitolite::AccessDenied, ex.message
- rescue Exception => ex
- log(ex.class.name + " " + ex.message)
- raise Gitolite::AccessDenied.new("gitolite timeout")
+ #rescue Exception => ex
+ #log(ex.class.name + " " + ex.message)
+ #raise Gitolite::AccessDenied.new("gitolite timeout")
end
def log message
@@ -202,25 +202,41 @@ module Gitlab
end
def push tmp_dir
- Dir.chdir(File.join(tmp_dir, "gitolite"))
- raise "Git add failed." unless system('git add -A')
- system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit
- raise "Git commit failed." unless [0,1].include? $?.exitstatus
+ output, status = popen('git add -A')
+ raise "Git add failed." unless status.zero?
- stdin, stdout, stderr = Open3.popen3('git push')
- push_output = stderr.read
- push_status = $?.to_i
+ # git commit returns 0 on success, and 1 if there is nothing to commit
+ output, status = popen('git commit -m "GitLab"')
+ raise "Git add failed." unless [0,1].include?(status)
- if push_output =~ /remote\: FATAL/
- raise BrokenGitolite, push_output
+ output, status = popen('git push')
+
+ if output =~ /remote\: FATAL/
+ raise BrokenGitolite, output
end
- if push_status.zero?
- Dir.chdir(Rails.root)
+ if status.zero? || output =~ /Everything up\-to\-date/
+ return true
else
raise PushError, "unable to push gitolite-admin repo"
end
end
+
+ def popen(cmd)
+ path = File.join(config_tmp_dir,'gitolite')
+ vars = { "PWD" => path }
+ options = { :chdir => path }
+
+ @cmd_output = ""
+ @cmd_status = 0
+ Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr|
+ @cmd_status = wait_thr.value.exitstatus
+ @cmd_output << stdout.read
+ @cmd_output << stderr.read
+ end
+
+ return @cmd_output, @cmd_status
+ end
end
end