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,