rosa-build/lib/tasks/migrate_repos_task.rake

32 lines
835 B
Ruby
Raw Normal View History

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 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 15:55:23 +01:00
repo_dirs.each do |repo_dir|
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:09:18 +01:00
puts "Creating project: #{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
project = main.projects.create(:name => project_name, :unixname => project_name)
puts "Executing: 'rm -rf #{project.git_repo_path}'"
`rm -rf #{project.git_repo_path}`
2011-04-27 16:14:52 +01:00
puts "Executing: 'cp -a #{repo_dir} #{project.git_repo_path}'"
`cp -a #{repo_dir} #{project.git_repo_path}`
2011-04-27 15:21:26 +01:00
end
end
end