Merge branch 'develop' into szzh

This commit is contained in:
huang 2015-11-10 15:31:44 +08:00
commit 0051733956
3 changed files with 73 additions and 56 deletions

View File

@ -1,22 +0,0 @@
#coding=utf-8
namespace :rep_fault do
desc "set ossean's type value"
task :rep_update => :environment do
rep = Repository.find(400)
rep.type = "Repository::Git"
rep.save
end
desc "forge and ossean's members"
task :sync_members => :environment do
projects = []
projects << Project.where("id =? ",2)
projects << Project.where("id =? ",299)
puts projects
s = Trustie::Gitlab::Sync.new
projects.each do |project|
s.only_members(project.first)
end
end
end

View File

@ -0,0 +1,39 @@
#coding=utf-8
namespace :gitlab do
desc "sync gitlab's users which lost in last sync"
task :add_gid => :environment do
users = User.find_by_sql("select * from users where gid is null")
s = Trustie::Gitlab::Sync.new
g = Gitlab.client
users.each do |user|
us = g.get("/users?search=#{user.mail}")
puts user.mail
if us.blank?
puts "55555555555555555"
s.sync_user(user)
else
# 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com
puts "66666666666666666666"
puts user.id
if Array === us
us.each do |u|
if u.email == user.mail
user.gid = u.id
user.save
end
end
end
end
end
end
task :sync_members => :environment do
projects = Project.all
s = Trustie::Gitlab::Sync.new
projects.each do |project|
puts project.id
s.only_members(project.first)
end
end
end