You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/11/14 19:37:02 UTC
[whimsy] branch master updated: Class to encapsulate the adding and
removal of committers
This is an automated email from the ASF dual-hosted git repository.
rubys 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 fa27e72 Class to encapsulate the adding and removal of committers
fa27e72 is described below
commit fa27e722436b7650b1c67bf8289729de750537e4
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Nov 14 14:36:42 2017 -0500
Class to encapsulate the adding and removal of committers
---
lib/whimsy/asf/ldap.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 2121ce5..6027c76 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -505,6 +505,50 @@ module ASF
end
end
+ # Manage committers: list, add, and remove people not only from the list
+ # of people, but from the list of committers.
+ class Committer < Base
+ @base = 'ou=role,ou=groups,dc=apache,dc=org'
+
+ # get a list of committers
+ def self.list()
+ ASF.search_one(base, 'cn=committers', 'member').flatten.
+ 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)
+ # add person to LDAP
+ person = ASF::Person.add(attrs)
+
+ # 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)
+
+ # return new person
+ person
+ end
+
+ # remove a committer from LDAP
+ def self.remove(person)
+ # if person is a string, find the person object
+ person = ASF::Person[person] if person.instance_of? String
+
+ # remove person to 'legacy' committers list, ignoring exceptions
+ ASF::Group['committers'].add(person) rescue nil
+
+ # remove person from 'new' committers list, ignoring exceptions
+ ASF::LDAP.modify("cn=committers,#@base",
+ [ASF::Base.mod_delete('member', [person.dn])]) rescue nil
+
+ # remove person from LDAP
+ ASF::Person.remove(person.id)
+ end
+ end
+
class Person < Base
@base = 'ou=people,dc=apache,dc=org'
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].
Re: [whimsy] branch master updated: Class to encapsulate the adding
and removal of committers
Posted by sebb <se...@gmail.com>.
On 14 November 2017 at 19:37, <ru...@apache.org> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> rubys 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 fa27e72 Class to encapsulate the adding and removal of committers
> fa27e72 is described below
>
> commit fa27e722436b7650b1c67bf8289729de750537e4
> Author: Sam Ruby <ru...@intertwingly.net>
> AuthorDate: Tue Nov 14 14:36:42 2017 -0500
>
> Class to encapsulate the adding and removal of committers
> ---
> lib/whimsy/asf/ldap.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
> index 2121ce5..6027c76 100644
> --- a/lib/whimsy/asf/ldap.rb
> +++ b/lib/whimsy/asf/ldap.rb
> @@ -505,6 +505,50 @@ module ASF
> end
> end
>
> + # Manage committers: list, add, and remove people not only from the list
> + # of people, but from the list of committers.
> + class Committer < Base
> + @base = 'ou=role,ou=groups,dc=apache,dc=org'
> +
> + # get a list of committers
> + def self.list()
> + ASF.search_one(base, 'cn=committers', 'member').flatten.
> + 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)
> + # add person to LDAP
> + person = ASF::Person.add(attrs)
> +
> + # 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)
> +
> + # return new person
> + person
> + end
> +
> + # remove a committer from LDAP
> + def self.remove(person)
> + # if person is a string, find the person object
> + person = ASF::Person[person] if person.instance_of? String
> +
> + # remove person to 'legacy' committers list, ignoring exceptions
> + ASF::Group['committers'].add(person) rescue nil
Comment does not agree with code; it's not clear which is correct.
> +
> + # remove person from 'new' committers list, ignoring exceptions
> + ASF::LDAP.modify("cn=committers,#@base",
> + [ASF::Base.mod_delete('member', [person.dn])]) rescue nil
> +
> + # remove person from LDAP
> + ASF::Person.remove(person.id)
> + end
> + end
> +
> class Person < Base
> @base = 'ou=people,dc=apache,dc=org'
>
>
> --
> To stop receiving notification emails like this one, please contact
> ['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].