summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2011-12-04 01:08:08 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2011-12-04 01:08:08 +0200
commitc03bc6e2912b2e63a352e1f7e664b32a95aa9cad (patch)
treea8adc7f9ded077b4209d2cb7a395574295d95e12 /lib
parent6a2c7d80cbfe33cca71c11339f3443d9c6a33069 (diff)
downloadgitlab-ce-c03bc6e2912b2e63a352e1f7e664b32a95aa9cad.tar.gz
gitolite support in progress | requires gitolite umask 0007
Diffstat (limited to 'lib')
-rw-r--r--lib/gitosis.rb39
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/gitosis.rb b/lib/gitosis.rb
index 92d32d8bf73..6aa32849fc3 100644
--- a/lib/gitosis.rb
+++ b/lib/gitosis.rb
@@ -1,3 +1,5 @@
+require 'gitolite'
+
require 'inifile'
require 'timeout'
require 'fileutils'
@@ -7,15 +9,15 @@ class Gitosis
def pull
# create tmp dir
- @local_dir = File.join(Dir.tmpdir,"gitlabhq-gitosis-#{Time.now.to_i}")
+ @local_dir = File.join(Dir.tmpdir,"gitlabhq-gitolite-#{Time.now.to_i}")
Dir.mkdir @local_dir
- `git clone #{GITOSIS['admin_uri']} #{@local_dir}/gitosis`
+ `git clone #{GITOSIS['admin_uri']} #{@local_dir}/gitolite`
end
def push
- Dir.chdir(File.join(@local_dir, "gitosis"))
+ Dir.chdir(File.join(@local_dir, "gitolite"))
`git add -A`
`git commit -am "Gitlab"`
`git push`
@@ -26,7 +28,7 @@ class Gitosis
def configure
status = Timeout::timeout(20) do
- File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f|
+ File.open(File.join(Dir.tmpdir,"gitlabhq-gitolite.lock"), "w+") do |f|
begin
f.flock(File::LOCK_EX)
pull
@@ -37,14 +39,14 @@ class Gitosis
end
end
end
- rescue Exception => ex
- raise Gitosis::AccessDenied.new("gitosis timeout")
+ #rescue Exception => ex
+ #raise Gitosis::AccessDenied.new("gitolite timeout")
end
def destroy_project(project)
`sudo -u git rm -rf #{project.path_to_repo}`
- conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf'))
+ conf = IniFile.new(File.join(@local_dir,'gitolite', 'conf', 'gitolite.conf'))
conf.delete_section("group #{project.path}")
@@ -53,22 +55,29 @@ class Gitosis
#update or create
def update_keys(user, key)
- File.open(File.join(@local_dir, 'gitosis/keydir',"#{user}.pub"), 'w') {|f| f.write(key.gsub(/\n/,'')) }
+ File.open(File.join(@local_dir, 'gitolite/keydir',"#{user}.pub"), 'w') {|f| f.write(key.gsub(/\n/,'')) }
end
def delete_key(user)
- File.unlink(File.join(@local_dir, 'gitosis/keydir',"#{user}.pub"))
- `cd #{File.join(@local_dir,'gitosis')} ; git rm keydir/#{user}.pub`
+ File.unlink(File.join(@local_dir, 'gitolite/keydir',"#{user}.pub"))
+ `cd #{File.join(@local_dir,'gitolite')} ; git rm keydir/#{user}.pub`
end
#update or create
def update_project(repo_name, name_writers)
- # write config file
- conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf'))
+ ga_repo = Gitolite::GitoliteAdmin.new(File.join(@local_dir,'gitolite'))
+ conf = ga_repo.config
- conf["group #{repo_name}"]['writable'] = repo_name
- conf["group #{repo_name}"]['members'] = name_writers.join(' ')
+ repo = if conf.has_repo?(repo_name)
+ conf.get_repo(repo_name)
+ else
+ Gitolite::Config::Repo.new(repo_name)
+ end
- conf.write
+ repo.add_permission("RW+", "", name_writers) unless name_writers.blank?
+
+ conf.add_repo(repo)
+
+ ga_repo.save
end
end