No gitolite in project any more

This commit is contained in:
Dmitriy Zaporozhets 2013-02-11 19:16:59 +02:00
parent 8e0b58d7e7
commit d64090b8a9
27 changed files with 117 additions and 159 deletions

View file

@ -144,7 +144,7 @@ namespace :gitlab do
task :restore => :environment do
backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
repos_path = Gitlab.config.gitolite.repos_path
repos_path = Gitlab.config.gitlab_shell.repos_path
puts "Restoring repositories ... "

View file

@ -1,7 +1,7 @@
namespace :gitlab do
desc "GITLAB | Check the configuration of GitLab and its environment"
task check: %w{gitlab:env:check
gitlab:gitolite:check
gitlab:gitlab_shell:check
gitlab:sidekiq:check
gitlab:app:check}
@ -296,10 +296,10 @@ namespace :gitlab do
# see https://github.com/gitlabhq/gitlabhq/issues/1059
def check_issue_1059_shell_profile_error
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
print "Has no \"-e\" in ~#{gitlab_shell_ssh_user}/.profile ... "
profile_file = File.join(gitolite_user_home, ".profile")
profile_file = File.join(gitlab_shell_user_home, ".profile")
unless File.read(profile_file) =~ /^-e PATH/
puts "yes".green
@ -367,7 +367,7 @@ namespace :gitlab do
namespace :gitolite do
namespace :gitlab_shell do
desc "GITLAB | Check the configuration of Gitolite"
task check: :environment do
warn_user_is_not_gitlab
@ -392,25 +392,25 @@ namespace :gitlab do
print "post-receive hook up-to-date? ... "
hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
unless File.exists?(gitolite_hook_file)
unless File.exists?(gitlab_shell_hook_file)
puts "can't check because of previous errors".magenta
return
end
gitolite_hook_content = File.read(gitolite_hook_file)
gitlab_shell_hook_content = File.read(gitlab_shell_hook_file)
gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
gitlab_hook_content = File.read(gitlab_hook_file)
if gitolite_hook_content == gitlab_hook_content
if gitlab_shell_hook_content == gitlab_hook_content
puts "yes".green
else
puts "no".red
try_fixing_it(
"sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}"
"sudo -u #{gitlab_shell_ssh_user} cp #{gitlab_hook_file} #{gitlab_shell_hook_file}"
)
for_more_information(
see_installation_guide_section "Setup GitLab Hooks"
@ -422,7 +422,7 @@ namespace :gitlab do
def check_repo_base_exists
print "Repo base directory exists? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
repo_base_path = Gitlab.config.gitlab_shell.repos_path
if File.exists?(repo_base_path)
puts "yes".green
@ -444,7 +444,7 @@ namespace :gitlab do
def check_repo_base_is_not_symlink
print "Repo base directory is a symlink? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta
return
@ -464,7 +464,7 @@ namespace :gitlab do
def check_repo_base_permissions
print "Repo base access is drwxrws---? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta
return
@ -487,23 +487,23 @@ namespace :gitlab do
end
def check_repo_base_user_and_group
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitolite_owner_group = Gitlab.config.gitolite.owner_group
print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_owner_group}? ... "
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
gitlab_shell_owner_group = Gitlab.config.gitlab_shell.owner_group
print "Repo base owned by #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group}? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta
return
end
if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitolite_owner_group)
if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group)
puts "yes".green
else
puts "no".red
try_fixing_it(
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_owner_group} #{repo_base_path}"
"sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}"
)
for_more_information(
see_installation_guide_section "Gitolite"
@ -516,11 +516,11 @@ namespace :gitlab do
print "post-receive hooks in repos are links: ... "
hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
unless File.exists?(gitolite_hook_file)
unless File.exists?(gitlab_shell_hook_file)
puts "can't check because of previous errors".magenta
return
end
@ -542,7 +542,7 @@ namespace :gitlab do
unless File.exists?(project_hook_file)
puts "missing".red
try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
"sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
)
for_more_information(
"lib/support/rewrite-hooks.sh"
@ -552,12 +552,12 @@ namespace :gitlab do
end
if File.lstat(project_hook_file).symlink? &&
File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
File.realpath(project_hook_file) == File.realpath(gitlab_shell_hook_file)
puts "ok".green
else
puts "not a link to Gitolite's hook".red
try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
"sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
)
for_more_information(
"lib/support/rewrite-hooks.sh"
@ -572,19 +572,19 @@ namespace :gitlab do
# Helper methods
########################
def gitolite_user_home
File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
def gitlab_shell_user_home
File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
end
def gitolite_version
gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION"
if File.readable?(gitolite_version_file)
File.read(gitolite_version_file)
def gitlab_shell_version
gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab_shell/src/VERSION"
if File.readable?(gitlab_shell_version_file)
File.read(gitlab_shell_version_file)
end
end
def has_gitolite3?
gitolite_version.try(:start_with?, "v3.")
def has_gitlab_shell3?
gitlab_shell_version.try(:start_with?, "v3.")
end
end

View file

@ -7,7 +7,7 @@ namespace :gitlab do
namespaces = Namespace.pluck(:path)
git_base_path = Gitlab.config.gitolite.repos_path
git_base_path = Gitlab.config.gitlab_shell.repos_path
all_dirs = Dir.glob(git_base_path + '/*')
puts git_base_path.yellow
@ -48,7 +48,7 @@ namespace :gitlab do
warn_user_is_not_gitlab
remove_flag = ENV['REMOVE']
git_base_path = Gitlab.config.gitolite.repos_path
git_base_path = Gitlab.config.gitlab_shell.repos_path
all_dirs = Dir.glob(git_base_path + '/*')
global_projects = Project.where(namespace_id: nil).pluck(:path)
@ -68,13 +68,6 @@ namespace :gitlab do
global_projects.include?(path)
end
# skip gitolite admin
all_dirs.reject! do |dir|
repo_name = File.basename dir
repo_name == 'gitolite-admin.git'
end
all_dirs.each do |dir_path|
if remove_flag
if FileUtils.rm_rf dir_path

View file

@ -6,11 +6,6 @@ namespace :gitlab do
migrate_user_namespaces
migrate_groups
migrate_projects
puts "Rebuild Gitolite ... "
gitolite = Gitlab::Gitolite.new
gitolite.update_repositories(Project.where('namespace_id IS NOT NULL'))
puts "... #{"done".green}"
end
def migrate_user_namespaces
@ -80,7 +75,7 @@ namespace :gitlab do
end
def migrate_projects
git_path = Gitlab.config.gitolite.repos_path
git_path = Gitlab.config.gitlab_shell.repos_path
puts "\nMove projects in groups into respective directories ... ".blue
Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
next unless project.group

View file

@ -12,7 +12,7 @@ namespace :gitlab do
desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance"
task :repos => :environment do
git_base_path = Gitlab.config.gitolite.repos_path
git_base_path = Gitlab.config.gitlab_shell.repos_path
repos_to_import = Dir.glob(git_base_path + '/*')
namespaces = Namespace.pluck(:path)
@ -26,7 +26,6 @@ namespace :gitlab do
# skip if not git repo
next unless repo_name =~ /.git$/
# skip gitolite admin
next if repo_name == 'gitolite-admin.git'
path = repo_name.sub(/\.git$/, '')

View file

@ -54,16 +54,16 @@ namespace :gitlab do
# check Gitolite version
gitolite_version_file = "#{Gitlab.config.gitolite.repos_path}/../gitlab-shell/VERSION"
if File.readable?(gitolite_version_file)
gitolite_version = File.read(gitolite_version_file)
gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.repos_path}/../gitlab-shell/VERSION"
if File.readable?(gitlab_shell_version_file)
gitlab_shell_version = File.read(gitlab_shell_version_file)
end
puts ""
puts "GitLab Shell".yellow
puts "Version:\t#{gitolite_version || "unknown".red}"
puts "Repositories:\t#{Gitlab.config.gitolite.repos_path}"
puts "Hooks:\t\t#{Gitlab.config.gitolite.hooks_path}"
puts "Version:\t#{gitlab_shell_version || "unknown".red}"
puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}"
puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
puts "Git:\t\t#{Gitlab.config.git.bin_path}"
end

View file

@ -8,7 +8,7 @@ namespace :gitlab do
desc "GITLAB | Build missing projects"
task build_missing_projects: :environment do
Project.find_each(batch_size: 1000) do |project|
path_to_repo = File.join(Gitlab.config.gitolite.repos_path, "#{project.path_with_namespace}.git")
path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
if File.exists?(path_to_repo)
print '-'
else

View file

@ -6,7 +6,7 @@ namespace :sidekiq do
desc "GITLAB | Start sidekiq"
task :start do
run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitolite,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &"
run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &"
end
def pidfile