gitolite support in progress | requires gitolite umask 0007
This commit is contained in:
parent
6a2c7d80cb
commit
c03bc6e291
1
Gemfile
1
Gemfile
|
@ -9,6 +9,7 @@ gem "kaminari"
|
||||||
gem "haml-rails"
|
gem "haml-rails"
|
||||||
gem "jquery-rails"
|
gem "jquery-rails"
|
||||||
gem "grit", :git => "https://github.com/gitlabhq/grit.git"
|
gem "grit", :git => "https://github.com/gitlabhq/grit.git"
|
||||||
|
gem "gitolite", :git => "https://github.com/gitlabhq/gitolite.git"
|
||||||
gem "carrierwave"
|
gem "carrierwave"
|
||||||
gem "six"
|
gem "six"
|
||||||
gem "therubyracer"
|
gem "therubyracer"
|
||||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -4,6 +4,14 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
annotate (2.4.1.beta1)
|
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
|
GIT
|
||||||
remote: https://github.com/gitlabhq/grit.git
|
remote: https://github.com/gitlabhq/grit.git
|
||||||
revision: ff015074ef35bd94cba943f9c0f98e161ab5851c
|
revision: ff015074ef35bd94cba943f9c0f98e161ab5851c
|
||||||
|
@ -101,6 +109,7 @@ GEM
|
||||||
activesupport (~> 3.0)
|
activesupport (~> 3.0)
|
||||||
haml (~> 3.0)
|
haml (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
|
hashery (1.4.0)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
inifile (0.4.1)
|
inifile (0.4.1)
|
||||||
|
@ -259,6 +268,7 @@ DEPENDENCIES
|
||||||
drapper
|
drapper
|
||||||
faker
|
faker
|
||||||
git
|
git
|
||||||
|
gitolite!
|
||||||
grit!
|
grit!
|
||||||
haml-rails
|
haml-rails
|
||||||
inifile
|
inifile
|
||||||
|
|
|
@ -8,7 +8,7 @@ email:
|
||||||
|
|
||||||
# Gitosis congiguration
|
# Gitosis congiguration
|
||||||
gitosis:
|
gitosis:
|
||||||
admin_uri: git@localhost:gitosis-admin.git
|
admin_uri: git@localhost:gitolite-admin
|
||||||
base_path: /home/git/repositories/
|
base_path: /home/git/repositories/
|
||||||
host: localhost
|
host: localhost
|
||||||
git_user: git
|
git_user: git
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'gitolite'
|
||||||
|
|
||||||
require 'inifile'
|
require 'inifile'
|
||||||
require 'timeout'
|
require 'timeout'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
@ -7,15 +9,15 @@ class Gitosis
|
||||||
|
|
||||||
def pull
|
def pull
|
||||||
# create tmp dir
|
# 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
|
Dir.mkdir @local_dir
|
||||||
|
|
||||||
`git clone #{GITOSIS['admin_uri']} #{@local_dir}/gitosis`
|
`git clone #{GITOSIS['admin_uri']} #{@local_dir}/gitolite`
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
Dir.chdir(File.join(@local_dir, "gitosis"))
|
Dir.chdir(File.join(@local_dir, "gitolite"))
|
||||||
`git add -A`
|
`git add -A`
|
||||||
`git commit -am "Gitlab"`
|
`git commit -am "Gitlab"`
|
||||||
`git push`
|
`git push`
|
||||||
|
@ -26,7 +28,7 @@ class Gitosis
|
||||||
|
|
||||||
def configure
|
def configure
|
||||||
status = Timeout::timeout(20) do
|
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
|
begin
|
||||||
f.flock(File::LOCK_EX)
|
f.flock(File::LOCK_EX)
|
||||||
pull
|
pull
|
||||||
|
@ -37,14 +39,14 @@ class Gitosis
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
#rescue Exception => ex
|
||||||
raise Gitosis::AccessDenied.new("gitosis timeout")
|
#raise Gitosis::AccessDenied.new("gitolite timeout")
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_project(project)
|
def destroy_project(project)
|
||||||
`sudo -u git rm -rf #{project.path_to_repo}`
|
`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}")
|
conf.delete_section("group #{project.path}")
|
||||||
|
|
||||||
|
@ -53,22 +55,29 @@ class Gitosis
|
||||||
|
|
||||||
#update or create
|
#update or create
|
||||||
def update_keys(user, key)
|
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
|
end
|
||||||
|
|
||||||
def delete_key(user)
|
def delete_key(user)
|
||||||
File.unlink(File.join(@local_dir, 'gitosis/keydir',"#{user}.pub"))
|
File.unlink(File.join(@local_dir, 'gitolite/keydir',"#{user}.pub"))
|
||||||
`cd #{File.join(@local_dir,'gitosis')} ; git rm keydir/#{user}.pub`
|
`cd #{File.join(@local_dir,'gitolite')} ; git rm keydir/#{user}.pub`
|
||||||
end
|
end
|
||||||
|
|
||||||
#update or create
|
#update or create
|
||||||
def update_project(repo_name, name_writers)
|
def update_project(repo_name, name_writers)
|
||||||
# write config file
|
ga_repo = Gitolite::GitoliteAdmin.new(File.join(@local_dir,'gitolite'))
|
||||||
conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf'))
|
conf = ga_repo.config
|
||||||
|
|
||||||
conf["group #{repo_name}"]['writable'] = repo_name
|
repo = if conf.has_repo?(repo_name)
|
||||||
conf["group #{repo_name}"]['members'] = name_writers.join(' ')
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue