From 81f8559c48f2cd9cdfcbc9887eeea657d6de47be Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 16:04:00 +0800 Subject: [PATCH] =?UTF-8?q?gitlab=E7=89=88=E6=9C=AC=E5=BA=93=E6=88=90?= =?UTF-8?q?=E5=91=98=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 --- lib/tasks/gitlab.rake | 16 ++++++++++++++++ lib/trustie/gitlab/sync.rb | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tasks/gitlab.rake b/lib/tasks/gitlab.rake index 729c9245f..bf43551c6 100644 --- a/lib/tasks/gitlab.rake +++ b/lib/tasks/gitlab.rake @@ -11,6 +11,22 @@ namespace :gitlab do end end + task :members => :environment do + projects = Project.where("gpid is not null") + s = Trustie::Gitlab::Sync.new + g = Gitlab.client + projects.each do |project| + begin + if project.members.count != g.team_members(project.gpid).count + puts project.id + s.only_members(project) + end + rescue => e + puts e + end + end + end + desc "update user password" task :password => :environment do s = Trustie::Gitlab::Sync.new diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index 2f4f77c53..3520098a9 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -122,7 +122,7 @@ module Trustie project.members.each do |m| begin gid = m.user.gid - unless gid + if gid.nil? gid = sync_user(m.user).id end self.g.add_team_member(project.gpid, gid, get_gitlab_role(m))