From a996e658a9d8b074bd6f3c4bf4d2f1699a069157 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 4 Nov 2015 14:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=B8=AA=E7=89=88=E6=9C=AC=E5=BA=93?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e_rep_if_fault.rake => gitlab_to_git.rake} | 0 lib/tasks/sync_sigle_rep.rake | 24 +++++++++++++++++++ lib/trustie/gitlab/sync.rb | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) rename lib/tasks/{update_rep_if_fault.rake => gitlab_to_git.rake} (100%) create mode 100644 lib/tasks/sync_sigle_rep.rake diff --git a/lib/tasks/update_rep_if_fault.rake b/lib/tasks/gitlab_to_git.rake similarity index 100% rename from lib/tasks/update_rep_if_fault.rake rename to lib/tasks/gitlab_to_git.rake diff --git a/lib/tasks/sync_sigle_rep.rake b/lib/tasks/sync_sigle_rep.rake new file mode 100644 index 000000000..6b7be700f --- /dev/null +++ b/lib/tasks/sync_sigle_rep.rake @@ -0,0 +1,24 @@ +#coding=utf-8 + +namespace :sync_rep do + desc "sync some projects which just have sigle repository" + task :sigle => :environment do + projects = Project.where("id =?",24) + 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 + puts rep.url + puts project.user_id + end + end + end +end \ No newline at end of file diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index 3a8e8380c..de4bec70b 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -66,7 +66,7 @@ module Trustie if opt[:password] import_url.sub('@', ":#{opt[:password]}@") end - + # import url http://xianbo_trustie2:1234@repository.trustie.net/xianbo/trustie2.git # can use password gproject = self.g.create_project(path,