单个版本库自动同步任务
This commit is contained in:
parent
d3cbcb38bd
commit
a996e658a9
|
@ -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
|
|
@ -66,7 +66,7 @@ module Trustie
|
||||||
if opt[:password]
|
if opt[:password]
|
||||||
import_url.sub('@', ":#{opt[:password]}@")
|
import_url.sub('@', ":#{opt[:password]}@")
|
||||||
end
|
end
|
||||||
|
|
||||||
# import url http://xianbo_trustie2:1234@repository.trustie.net/xianbo/trustie2.git
|
# import url http://xianbo_trustie2:1234@repository.trustie.net/xianbo/trustie2.git
|
||||||
# can use password
|
# can use password
|
||||||
gproject = self.g.create_project(path,
|
gproject = self.g.create_project(path,
|
||||||
|
|
Loading…
Reference in New Issue