socialforge/lib/tasks/sync_sigle_rep.rake

22 lines
737 B
Ruby
Raw Normal View History

2015-11-04 14:50:39 +08:00
#coding=utf-8
namespace :sync_rep do
desc "sync some projects which just have sigle repository"
task :sigle => :environment do
2015-11-04 16:19:25 +08:00
projects = Project.all
2015-11-04 14:50:39 +08:00
projects.each do |project|
# 针对类型为Git并且只有一个版本库的项目
if project.repositories && project.repositories.count == 1 && project.repositories.first.type == "Repository::Git"
rep = project.repositories.first
s = Trustie::Gitlab::Sync.new
s.sync_project(project, path: rep.identifier, import_url: rep.url)
rep.type = 'Repository::Gitlab'
rep.save
puts "*************************************"
puts project.id
puts rep.id
puts rep.identifier
end
end
end
end