You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2021/07/03 21:21:10 UTC
[whimsy] branch master updated: Move iclas.txt accesses to library
code
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 800160d Move iclas.txt accesses to library code
800160d is described below
commit 800160ddd2c2afc03485db741854b510b831eec3
Author: Sebb <se...@apache.org>
AuthorDate: Sat Jul 3 22:21:02 2021 +0100
Move iclas.txt accesses to library code
---
lib/whimsy/asf/icla.rb | 14 ++++++++++++++
www/officers/acreq.cgi | 18 +++++-------------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/lib/whimsy/asf/icla.rb b/lib/whimsy/asf/icla.rb
index 560d920..ec3ad6f 100644
--- a/lib/whimsy/asf/icla.rb
+++ b/lib/whimsy/asf/icla.rb
@@ -149,6 +149,20 @@ module ASF
end
end
+ # return a hash of unlisted ICLA names, keyed by email
+ # if age > 0, return the entries added in the last n days
+ def self.unlisted_name_by_email(age=0, env=nil)
+ if age > 0
+ rev = "{%s}:HEAD" % (Date.today - age)
+ diff, _err = ASF::SVN.svn('diff', SOURCE_URL, {revision: rev, env: env})
+ raise _err unless diff
+ return Hash[*diff.scan(/^[+]notinavail:.*?:(.*?):(.*?):Signed CLA/).flatten.reverse]
+ end
+ hash = {}
+ self.each { |icla| hash[icla.email] = icla.name if icla.noId? }
+ hash
+ end
+
# show the original entry (reconstructed for now)
def as_line
[id, legal_name, name, email, form].join(':')
diff --git a/www/officers/acreq.cgi b/www/officers/acreq.cgi
index 6a84ded..0c0b4f3 100755
--- a/www/officers/acreq.cgi
+++ b/www/officers/acreq.cgi
@@ -16,13 +16,9 @@ unless user.asf_member? or ASF.pmc_chairs.include? user
exit
end
-ICLAS = ASF::SVN.svnpath!('officers', 'iclas.txt')
-
# get up to date data...
requests, _err = ASF::SVN.svn('cat', ASF::SVN.svnpath!('acreq', 'new-account-reqs.txt'), {env: env})
-iclas_txt, _err = ASF::SVN.svn('cat', ICLAS, {env: env}).force_encoding('utf-8')
-
# grab the current list of PMCs from ldap
pmcs = ASF::Committee.pmcs.map(&:name).sort
@@ -42,16 +38,12 @@ query = CGI::parse ENV['QUERY_STRING']
iclas = Array(query['iclas']).last
email = Array(query['email']).last
if iclas == 'all'
- iclas = Hash[*iclas_txt.scan(/^notinavail:.*?:(.*?):(.*?):Signed CLA/).
- flatten.reverse]
-elsif iclas == '1' and email and iclas_txt =~ /^notinavail:.*?:(.*?):#{Regexp.escape(email)}:/
- iclas = {email => $1}
+ iclas = ASF::ICLA.unlisted_name_by_email
+elsif iclas == '1' and email and (icla = ASF::ICLA.find_by_email(email)) and icla.noId?
+ iclas = {email => icla.name}
else
- count = iclas ? iclas.to_i : 300 rescue 300
- log, _err = ASF::SVN.svn(['log', '--incremental', '-q', "-l#{count}"], ICLAS, {revision: 'HEAD:0', env: env})
- oldrev = log.split("\n")[-1].split()[0][1..-1].to_i
- diff, _err = ASF::SVN.svn('diff', ICLAS, {revision: "#{oldrev}:HEAD", env: env})
- iclas = Hash[*diff.scan(/^[+]notinavail:.*?:(.*?):(.*?):Signed CLA/).flatten.reverse]
+ count = iclas ? iclas.to_i : 100 rescue 100
+ iclas = ASF::ICLA.unlisted_name_by_email(count, env)
end
# grab the list of userids that have been assigned (for validation purposes)