rosa-build/lib/tasks/migrate_repos_task.rake

35 lines
867 B
Ruby
Raw Normal View History

2011-04-27 15:21:26 +01:00
namespace :repositories do
desc "Migrate repositories from fs"
2014-01-21 04:51:49 +00:00
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
cooker = Platform.find_by! name: "cooker"
main = cooker.repositories.find_by! name: "main"
2011-04-27 15:21:26 +01:00
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
if main.projects.find_by name: project_name
2011-04-27 16:09:18 +01:00
puts "\t Already created. Skipping"
next
end
2014-01-21 04:51:49 +00:00
project = main.projects.create(name: project_name, name: project_name)
2011-04-27 16:09:18 +01:00
puts "Executing: 'rm -rf #{project.path}'"
`rm -rf #{project.path}`
2011-04-27 16:14:52 +01: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