Commit c48c0f95b279e3fdaf0764d48711304beaa8ace8

Authored by randx
1 parent e8e8ca94

Gitlab::Gitolite final fixes. Seems like all functionality is working correctly now

Showing 1 changed file with 41 additions and 39 deletions   Show diff stats
lib/gitlab/backend/gitolite.rb
@@ -10,14 +10,14 @@ module Gitlab @@ -10,14 +10,14 @@ module Gitlab
10 def set_key key_id, key_content, projects 10 def set_key key_id, key_content, projects
11 configure do |c| 11 configure do |c|
12 c.update_keys(key_id, key_content) 12 c.update_keys(key_id, key_content)
13 - c.update_project(project.path, projects) 13 + c.update_projects(projects)
14 end 14 end
15 end 15 end
16 16
17 def remove_key key_id, projects 17 def remove_key key_id, projects
18 configure do |c| 18 configure do |c|
19 c.delete_key(key_id) 19 c.delete_key(key_id)
20 - c.update_project(project.path, projects) 20 + c.update_projects(projects)
21 end 21 end
22 end 22 end
23 23
@@ -50,43 +50,7 @@ module Gitlab @@ -50,43 +50,7 @@ module Gitlab
50 end 50 end
51 end 51 end
52 52
53 - private  
54 -  
55 - def pull  
56 - # create tmp dir  
57 - @local_dir = File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}")  
58 - Dir.mkdir @local_dir  
59 -  
60 - `git clone #{Gitlab.config.gitolite_admin_uri} #{@local_dir}/gitolite`  
61 - end  
62 -  
63 - def push  
64 - Dir.chdir(File.join(@local_dir, "gitolite"))  
65 - `git add -A`  
66 - `git commit -am "Gitlab"`  
67 - `git push`  
68 - Dir.chdir(Rails.root)  
69 -  
70 - FileUtils.rm_rf(@local_dir)  
71 - end  
72 -  
73 - def configure  
74 - Timeout::timeout(30) do  
75 - File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f|  
76 - begin  
77 - f.flock(File::LOCK_EX)  
78 - pull  
79 - yield(self)  
80 - push  
81 - ensure  
82 - f.flock(File::LOCK_UN)  
83 - end  
84 - end  
85 - end  
86 - rescue Exception => ex  
87 - Gitlab::Logger.error(ex.message)  
88 - raise Gitolite::AccessDenied.new("gitolite timeout")  
89 - end 53 + protected
90 54
91 def destroy_project(project) 55 def destroy_project(project)
92 FileUtils.rm_rf(project.path_to_repo) 56 FileUtils.rm_rf(project.path_to_repo)
@@ -191,5 +155,43 @@ module Gitlab @@ -191,5 +155,43 @@ module Gitlab
191 conf.add_repo(repo, true) 155 conf.add_repo(repo, true)
192 ga_repo.save 156 ga_repo.save
193 end 157 end
  158 +
  159 + private
  160 +
  161 + def pull
  162 + # create tmp dir
  163 + @local_dir = File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}")
  164 + Dir.mkdir @local_dir
  165 +
  166 + `git clone #{Gitlab.config.gitolite_admin_uri} #{@local_dir}/gitolite`
  167 + end
  168 +
  169 + def push
  170 + Dir.chdir(File.join(@local_dir, "gitolite"))
  171 + `git add -A`
  172 + `git commit -am "Gitlab"`
  173 + `git push`
  174 + Dir.chdir(Rails.root)
  175 +
  176 + FileUtils.rm_rf(@local_dir)
  177 + end
  178 +
  179 + def configure
  180 + Timeout::timeout(30) do
  181 + File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f|
  182 + begin
  183 + f.flock(File::LOCK_EX)
  184 + pull
  185 + yield(self)
  186 + push
  187 + ensure
  188 + f.flock(File::LOCK_UN)
  189 + end
  190 + end
  191 + end
  192 + rescue Exception => ex
  193 + Gitlab::Logger.error(ex.message)
  194 + raise Gitolite::AccessDenied.new("gitolite timeout")
  195 + end
194 end 196 end
195 end 197 end