2011-04-27 15:21:26 +01:00
|
|
|
namespace :repositories do
|
|
|
|
|
|
|
|
desc "Migrate repositories from fs"
|
|
|
|
task :migrate => :environment do
|
2011-04-27 15:55:23 +01:00
|
|
|
repo_dirs = Dir["/root/mandriva_main_git/*.git"]
|
2011-04-27 16:30:12 +01:00
|
|
|
total = repo_dirs.length
|
2011-04-27 15:38:59 +01:00
|
|
|
|
2011-04-27 15:21:26 +01:00
|
|
|
cooker = Platform.find_by_name!("cooker")
|
|
|
|
main = cooker.repositories.find_by_name!("main")
|
|
|
|
|
2011-04-27 16:30:12 +01:00
|
|
|
repo_dirs.each_with_index do |repo_dir, index|
|
2011-04-27 15:56:55 +01:00
|
|
|
project_name = File.basename(repo_dir, ".git")
|
2011-04-27 15:55:23 +01:00
|
|
|
|
2011-04-27 16:30:12 +01:00
|
|
|
puts "Creating project(#{index}/#{total}): #{project_name}"
|
2011-04-27 15:21:26 +01:00
|
|
|
|
2011-04-27 16:11:32 +01:00
|
|
|
if main.projects.find_by_name(project_name)
|
2011-04-27 16:09:18 +01:00
|
|
|
puts "\t Already created. Skipping"
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2011-11-28 15:41:42 +00:00
|
|
|
project = main.projects.create(:name => project_name, :name => project_name)
|
2011-04-27 16:09:18 +01:00
|
|
|
|
2011-11-23 15:52:33 +00:00
|
|
|
puts "Executing: 'rm -rf #{project.path}'"
|
|
|
|
`rm -rf #{project.path}`
|
2011-04-27 16:14:52 +01:00
|
|
|
|
2011-11-23 15:52:33 +00:00
|
|
|
puts "Executing: 'cp -a #{repo_dir} #{project.path}'"
|
|
|
|
`cp -a #{repo_dir} #{project.path}`
|
2011-04-27 16:30:12 +01:00
|
|
|
|
|
|
|
puts ""
|
2011-04-27 15:21:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|