2012-04-04 00:02:54 +02:00
|
|
|
namespace :gitlab do
|
|
|
|
namespace :gitolite do
|
|
|
|
desc "GITLAB | Rebuild each project at gitolite config"
|
2012-09-26 13:18:10 +02:00
|
|
|
task :update_repos => :environment do
|
2012-04-04 00:02:54 +02:00
|
|
|
puts "Starting Projects"
|
|
|
|
Project.find_each(:batch_size => 100) do |project|
|
2012-09-26 13:18:10 +02:00
|
|
|
puts "\n=== #{project.name}"
|
2012-04-04 00:02:54 +02:00
|
|
|
project.update_repository
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
puts "Done with projects"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "GITLAB | Rebuild each key at gitolite config"
|
|
|
|
task :update_keys => :environment do
|
|
|
|
puts "Starting Key"
|
|
|
|
Key.find_each(:batch_size => 100) do |key|
|
2012-08-28 23:04:06 +02:00
|
|
|
Gitlab::Gitolite.new.set_key(key.identifier, key.key, key.projects)
|
2012-04-04 00:02:54 +02:00
|
|
|
print '.'
|
|
|
|
end
|
|
|
|
puts "Done with keys"
|
|
|
|
end
|
2012-12-24 19:01:49 +01:00
|
|
|
|
|
|
|
desc "GITLAB | Cleanup gitolite config"
|
|
|
|
task :cleanup => :environment do
|
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
|
|
|
real_repos = Project.all.map(&:path_with_namespace)
|
|
|
|
real_repos << "gitolite-admin"
|
|
|
|
real_repos << "@all"
|
|
|
|
|
|
|
|
remove_flag = ENV['REMOVE']
|
|
|
|
|
|
|
|
puts "Looking for repositories to remove... "
|
|
|
|
Gitlab::GitoliteConfig.new.apply do |config|
|
|
|
|
all_repos = []
|
|
|
|
garbage_repos = []
|
|
|
|
|
|
|
|
all_repos = config.conf.repos.keys
|
|
|
|
garbage_repos = all_repos - real_repos
|
|
|
|
|
|
|
|
garbage_repos.each do |repo_name|
|
|
|
|
if remove_flag
|
|
|
|
config.conf.rm_repo(repo_name)
|
|
|
|
print "to remove...".red
|
|
|
|
end
|
|
|
|
|
|
|
|
puts repo_name.red
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
unless remove_flag
|
|
|
|
puts "To cleanup repositories run this command with REMOVE=true".yellow
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 00:02:54 +02:00
|
|
|
end
|
|
|
|
end
|