gitlab迁移任务

dev_course
jingquan huang 6 years ago
parent cd41197a46
commit 2880e8ac25

@ -10,7 +10,7 @@ namespace :sync do
puts repo_name
myshixun.update_column(:repo_name, repo_name)
rescue Exception => e
Rails.logger.error("e.message")
Rails.logger.error("#{e.message}")
end
end
end
@ -26,7 +26,27 @@ namespace :sync do
puts repo_name
shixun.update_column(:repo_name, repo_name)
rescue Exception => e
Rails.logger.error("e.message")
Rails.logger.error("#{e.message}")
end
end
end
task :check => :environment do
g = Gitlab.client
shixuns = Shixun.where("repo_name is null and fork_from is not null")
shixuns.find_each do |shixun|
begin
puts shixun.identifier
original_shixun = Shixun.find(fork_from)
gshixun = g.fork(original_shixun.gpid, shixun.owner.try(:gid))
repo_name = g.project(gshixun.id).path_with_namespace
puts repo_name
shixun.update_attributes(:repo_name => repo_name, :gpid => gshixun.id)
rescue Exception => e
Rails.logger.error("#{e.message}")
end
end
end

Loading…
Cancel
Save