From 2880e8ac25a3bd5383f40df22044acbe00857605 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 21 Jun 2019 17:04:40 +0800 Subject: [PATCH] =?UTF-8?q?gitlab=E8=BF=81=E7=A7=BB=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/gitlab.rake | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gitlab.rake b/lib/tasks/gitlab.rake index 396f197d3..0d872991b 100644 --- a/lib/tasks/gitlab.rake +++ b/lib/tasks/gitlab.rake @@ -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