Commit 162c4b044ee0890e774c30b19d17c0c5988c82d3

Authored by gitlabhq
1 parent 25c9cbff

issue #94

Showing 3 changed files with 24 additions and 16 deletions   Show diff stats
@@ -8,7 +8,7 @@ gem 'stamp' @@ -8,7 +8,7 @@ gem 'stamp'
8 gem 'will_paginate', '~> 3.0' 8 gem 'will_paginate', '~> 3.0'
9 gem 'haml-rails' 9 gem 'haml-rails'
10 gem 'jquery-rails' 10 gem 'jquery-rails'
11 -gem 'grit' 11 +gem 'grit', :git => 'git://github.com/mojombo/grit.git'
12 gem "carrierwave" 12 gem "carrierwave"
13 gem 'six' 13 gem 'six'
14 gem 'therubyracer' 14 gem 'therubyracer'
@@ -14,6 +14,15 @@ GIT @@ -14,6 +14,15 @@ GIT
14 activesupport (~> 3.1.0.rc4) 14 activesupport (~> 3.1.0.rc4)
15 15
16 GIT 16 GIT
  17 + remote: git://github.com/mojombo/grit.git
  18 + revision: ff015074ef35bd94cba943f9c0f98e161ab5851c
  19 + specs:
  20 + grit (2.4.1)
  21 + diff-lcs (~> 1.1)
  22 + mime-types (~> 1.15)
  23 + posix-spawn (~> 0.3.6)
  24 +
  25 +GIT
17 remote: git://github.com/randx/albino.git 26 remote: git://github.com/randx/albino.git
18 revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 27 revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1
19 specs: 28 specs:
@@ -98,9 +107,6 @@ GEM @@ -98,9 +107,6 @@ GEM
98 i18n (~> 0.4) 107 i18n (~> 0.4)
99 ffi (1.0.9) 108 ffi (1.0.9)
100 git (1.2.5) 109 git (1.2.5)
101 - grit (2.4.1)  
102 - diff-lcs (~> 1.1)  
103 - mime-types (~> 1.15)  
104 haml (3.1.3) 110 haml (3.1.3)
105 haml-rails (0.3.4) 111 haml-rails (0.3.4)
106 actionpack (~> 3.0) 112 actionpack (~> 3.0)
@@ -247,7 +253,7 @@ DEPENDENCIES @@ -247,7 +253,7 @@ DEPENDENCIES
247 devise (= 1.4.7) 253 devise (= 1.4.7)
248 faker 254 faker
249 git 255 git
250 - grit 256 + grit!
251 haml-rails 257 haml-rails
252 inifile 258 inifile
253 jquery-rails 259 jquery-rails
lib/gitosis.rb
1 require 'inifile' 1 require 'inifile'
2 require 'timeout' 2 require 'timeout'
  3 +require 'fileutils'
  4 +
3 class Gitosis 5 class Gitosis
4 class AccessDenied < StandardError; end 6 class AccessDenied < StandardError; end
5 7
6 def pull 8 def pull
7 # create tmp dir 9 # create tmp dir
8 - @local_dir = File.join(Dir.tmpdir,"gitme-gitosis-#{Time.now.to_i}") 10 + @local_dir = File.join(Dir.tmpdir,"gitlabhq-gitosis-#{Time.now.to_i}")
9 11
10 Dir.mkdir @local_dir 12 Dir.mkdir @local_dir
11 13
@@ -17,27 +19,27 @@ class Gitosis @@ -17,27 +19,27 @@ class Gitosis
17 @repo.commit_all "Gitlab" 19 @repo.commit_all "Gitlab"
18 @repo.push 20 @repo.push
19 21
20 - `rm -Rf #{@local_dir}` 22 + #FileUtils.rm_rf(@local_dir)
21 end 23 end
22 24
23 def configure 25 def configure
24 - status = Timeout::timeout(5) {  
25 - File.open(File.join(Dir.tmpdir,"gitme-gitosis.lock"), "w+") do |f|  
26 - f.flock(File::LOCK_EX) 26 + status = Timeout::timeout(5) do
  27 + File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f|
  28 + f.flock(File::LOCK_EX)
27 29
28 - pull  
29 - yield(self)  
30 - push 30 + pull
  31 + yield(self)
  32 + push
31 33
32 - f.flock(File::LOCK_UN) 34 + f.flock(File::LOCK_UN)
33 end 35 end
34 - } 36 + end
35 rescue Exception => ex 37 rescue Exception => ex
36 raise Gitosis::AccessDenied.new("gitosis timeout") 38 raise Gitosis::AccessDenied.new("gitosis timeout")
37 end 39 end
38 40
39 def destroy_project(project) 41 def destroy_project(project)
40 - `rm -Rf #{project.path_to_repo}` 42 + #FileUtils.rm_rf(project.path_to_repo)
41 43
42 conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf')) 44 conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf'))
43 45