Commit 162c4b044ee0890e774c30b19d17c0c5988c82d3
1 parent
25c9cbff
Exists in
master
and in
4 other branches
issue #94
Showing
3 changed files
with
24 additions
and
16 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -14,6 +14,15 @@ GIT |
14 | 14 | activesupport (~> 3.1.0.rc4) |
15 | 15 | |
16 | 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 | 26 | remote: git://github.com/randx/albino.git |
18 | 27 | revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 |
19 | 28 | specs: |
... | ... | @@ -98,9 +107,6 @@ GEM |
98 | 107 | i18n (~> 0.4) |
99 | 108 | ffi (1.0.9) |
100 | 109 | git (1.2.5) |
101 | - grit (2.4.1) | |
102 | - diff-lcs (~> 1.1) | |
103 | - mime-types (~> 1.15) | |
104 | 110 | haml (3.1.3) |
105 | 111 | haml-rails (0.3.4) |
106 | 112 | actionpack (~> 3.0) |
... | ... | @@ -247,7 +253,7 @@ DEPENDENCIES |
247 | 253 | devise (= 1.4.7) |
248 | 254 | faker |
249 | 255 | git |
250 | - grit | |
256 | + grit! | |
251 | 257 | haml-rails |
252 | 258 | inifile |
253 | 259 | jquery-rails | ... | ... |
lib/gitosis.rb
1 | 1 | require 'inifile' |
2 | 2 | require 'timeout' |
3 | +require 'fileutils' | |
4 | + | |
3 | 5 | class Gitosis |
4 | 6 | class AccessDenied < StandardError; end |
5 | 7 | |
6 | 8 | def pull |
7 | 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 | 12 | Dir.mkdir @local_dir |
11 | 13 | |
... | ... | @@ -17,27 +19,27 @@ class Gitosis |
17 | 19 | @repo.commit_all "Gitlab" |
18 | 20 | @repo.push |
19 | 21 | |
20 | - `rm -Rf #{@local_dir}` | |
22 | + #FileUtils.rm_rf(@local_dir) | |
21 | 23 | end |
22 | 24 | |
23 | 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 | 35 | end |
34 | - } | |
36 | + end | |
35 | 37 | rescue Exception => ex |
36 | 38 | raise Gitosis::AccessDenied.new("gitosis timeout") |
37 | 39 | end |
38 | 40 | |
39 | 41 | def destroy_project(project) |
40 | - `rm -Rf #{project.path_to_repo}` | |
42 | + #FileUtils.rm_rf(project.path_to_repo) | |
41 | 43 | |
42 | 44 | conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf')) |
43 | 45 | ... | ... |