This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a94408  Rename methods that should rarely be used
1a94408 is described below

commit 1a94408685e791051a2c3e90909eb98713ace8bb
Author: Sebb <[email protected]>
AuthorDate: Mon Dec 18 22:20:01 2017 +0000

    Rename methods that should rarely be used
    
    Add methods to update old & new committers LDAP groups
---
 lib/whimsy/asf/ldap.rb | 46 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index a42b3af..7d4571e 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -535,8 +535,9 @@ module ASF
         map {|uid| Person.find uid[/uid=(.*?),/,1]}
     end
 
-    # add a new committer to LDAP.  Attrs must include uid, cn, and mail
-    def self.add(attrs)
+    # create a new person and add as a new committer to LDAP.
+    # Attrs must include uid, cn, and mail
+    def self.create(attrs)
       # add person to LDAP
       person = ASF::Person.add(attrs)
 
@@ -551,8 +552,10 @@ module ASF
       person
     end
 
-    # remove a committer from LDAP
-    def self.remove(person)
+    # completely remove a committer from LDAP
+    # ** DO NOT USE **
+    # In almost all cases, use deregister instead
+    def self.destroy(person)
       # if person is a string, find the person object
       person = ASF::Person.find(person) if person.instance_of? String
 
@@ -563,9 +566,42 @@ module ASF
       ASF::LDAP.modify("cn=committers,#@base", 
         [ASF::Base.mod_delete('member', [person.dn])]) rescue nil
 
-      # remove person from LDAP
+      # remove person from LDAP (should almost never be done)
       ASF::Person.remove(person.id)
     end
+
+    # register an existing person as a committer
+    # updates both committer LDAP groups
+    def self.register(person)
+      if person.instance_of? String
+        id = person # save for use in error message
+        person = ASF::Person[person] or raise ArgumentError.new("Cannot find 
person: '#{id}'") 
+      end
+
+      # add person to 'new' committers list
+      ASF::LDAP.modify("cn=committers,#@base", 
+        [ASF::Base.mod_add('member', [person.dn])])
+
+      # add person to 'legacy' committers list
+      ASF::Group['committers'].add(person)
+    end
+
+    # deregister an existing person as a committer
+    # updates both committer LDAP groups
+    def self.deregister(person)
+      if person.instance_of? String
+        id = person # save for use in error message
+        person = ASF::Person[person] or raise ArgumentError.new("Cannot find 
person: '#{id}'") 
+      end
+
+      # remove person from 'legacy' committers list
+      ASF::Group['committers'].remove(person)
+
+      # remove person from 'new' committers list
+      ASF::LDAP.modify("cn=committers,#@base", 
+        [ASF::Base.mod_delete('member', [person.dn])])
+    end
+
   end
 
   class Person < Base

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to