whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: avoid removing people who are not there
Date Wed, 06 Apr 2016 12:46:42 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  5631c57   avoid removing people who are not there
5631c57 is described below

commit 5631c57294729efe4b54ba7e3fa74849f67f03ab
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Wed Apr 6 08:46:12 2016 -0400

    avoid removing people who are not there
    
    and avoid adding people who already are
---
 lib/whimsy/asf/ldap.rb | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 3eee18a..3201d04 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -467,7 +467,8 @@ module ASF
     end
 
     def remove(people)
-      people = Array(people).map(&:id)
+      people = (Array(people) & members).map(&:id)
+      return if people.empty?
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_DELETE, 'memberUid', people)
       ASF.ldap.modify(self.dn, [mod])
     ensure
@@ -475,7 +476,8 @@ module ASF
     end
 
     def add(people)
-      people = Array(people).map(&:id)
+      people = (Array(people) - members).map(&:id)
+      return if people.empty?
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_ADD, 'memberUid', people)
       ASF.ldap.modify(self.dn, [mod])
     ensure
@@ -521,7 +523,7 @@ module ASF
     end
 
     def remove(people)
-      people = Array(people).map(&:dn)
+      people = Array(people & members).map(&:dn)
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_DELETE, 'member', people)
       ASF.ldap.modify(self.dn, [mod])
     ensure
@@ -529,7 +531,7 @@ module ASF
     end
 
     def add(people)
-      people = Array(people).map(&:dn)
+      people = Array(people - members).map(&:dn)
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_ADD, 'member', people)
       ASF.ldap.modify(self.dn, [mod])
     ensure
@@ -575,14 +577,14 @@ module ASF
     end
 
     def remove(people)
-      people = Array(people).map(&:dn)
+      people = Array(people - members).map(&:dn)
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_DELETE, 'member', people)
       ASF.ldap.modify(self.dn, [mod])
       @members = nil
     end
 
     def add(people)
-      people = Array(people).map(&:dn)
+      people = Array(people & members).map(&:dn)
       mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_ADD, 'member', people)
       ASF.ldap.modify(self.dn, [mod])
       @members = nil

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message