Commit c03bc6e2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

gitolite support in progress | requires gitolite umask 0007

parent 6a2c7d80
......@@ -9,6 +9,7 @@ gem "kaminari"
gem "haml-rails"
gem "jquery-rails"
gem "grit", :git => "https://github.com/gitlabhq/grit.git"
gem "gitolite", :git => "https://github.com/gitlabhq/gitolite.git"
gem "carrierwave"
gem "six"
gem "therubyracer"
......
......@@ -4,6 +4,14 @@ GIT
specs:
annotate (2.4.1.beta1)
GIT
remote: https://github.com/gitlabhq/gitolite.git
revision: 36dabd226caa40ff052677719adaacbfe667b36c
specs:
gitolite (0.0.3.alpha)
grit (~> 2.4.1)
hashery (~> 1.4.0)
GIT
remote: https://github.com/gitlabhq/grit.git
revision: ff015074ef35bd94cba943f9c0f98e161ab5851c
......@@ -101,6 +109,7 @@ GEM
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
hashery (1.4.0)
hike (1.2.1)
i18n (0.6.0)
inifile (0.4.1)
......@@ -259,6 +268,7 @@ DEPENDENCIES
drapper
faker
git
gitolite!
grit!
haml-rails
inifile
......
......@@ -8,7 +8,7 @@ email:
# Gitosis congiguration
gitosis:
admin_uri: git@localhost:gitosis-admin.git
admin_uri: git@localhost:gitolite-admin
base_path: /home/git/repositories/
host: localhost
git_user: git
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment