diff options
author | Jeremy Mack <jmacktdkc@gmail.com> | 2011-12-20 18:52:04 +0400 |
---|---|---|
committer | Jeremy Mack <jmacktdkc@gmail.com> | 2011-12-20 19:07:55 +0400 |
commit | 8a1deea58673b66cd99e06877914ef32b15f3944 (patch) | |
tree | d6848b518323f1d10369250cc97228d788981880 /lib | |
parent | 6d5c9698726e268a9cd392a5782c055031bb1bb9 (diff) |
Fixes timeout when adding an SSH key
Users with many projects (>100) will hit the 20 second timeout when
updating the gitolite config. This fix batches those changes into a
signle update to the file, causing an order of magnitude speed increase
which finishes well below the 20 second timeout.
Fixes gitlabhq/gitlabhq#220
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlabhq/gitolite.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/gitlabhq/gitolite.rb b/lib/gitlabhq/gitolite.rb index e79afb55577..0822c25e621 100644 --- a/lib/gitlabhq/gitolite.rb +++ b/lib/gitlabhq/gitolite.rb @@ -81,5 +81,33 @@ module Gitlabhq ga_repo.save end + + # Updates many projects and uses project.path as the repo path + # An order of magnitude faster than update_project + def update_projects(projects) + ga_repo = ::Gitolite::GitoliteAdmin.new(File.join(@local_dir,'gitolite')) + conf = ga_repo.config + + projects.each do |project| + repo_name = project.path + + repo = if conf.has_repo?(repo_name) + conf.get_repo(repo_name) + else + ::Gitolite::Config::Repo.new(repo_name) + end + + name_readers = project.repository_readers + name_writers = project.repository_writers + + repo.clean_permissions + repo.add_permission("R", "", name_readers) unless name_readers.blank? + repo.add_permission("RW+", "", name_writers) unless name_writers.blank? + conf.add_repo(repo, true) + end + + ga_repo.save + end + end end |