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 5d994f88 Utility methods for updating member noms file
5d994f88 is described below

commit 5d994f881d58cc6401600dd6897c37ce34b1c8ba
Author: Sebb <[email protected]>
AuthorDate: Tue Jan 31 21:45:36 2023 +0000

    Utility methods for updating member noms file
---
 lib/whimsy/asf/member-files.rb | 46 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/lib/whimsy/asf/member-files.rb b/lib/whimsy/asf/member-files.rb
index bed0fe55..2044808a 100644
--- a/lib/whimsy/asf/member-files.rb
+++ b/lib/whimsy/asf/member-files.rb
@@ -69,6 +69,52 @@ module ASF
       end
     end
 
+    # create a nomination entry in the standard format
+    #
+    def self.make_member_nomination(fields = {})
+      availid = fields[:availid] or raise ArgumentError.new(":availid is 
required")
+      publicname = ASF::Person[availid]&.cn or raise 
ArgumentError.new(":availid is invalid")
+      nomby = fields[:nomby] or raise ArgumentError.new(":nomby is required")
+      ASF::Person[nomby]&.dn or raise ArgumentError.new(":nomby is invalid")
+      secby = fields[:secby] || ''
+      statement = fields[:statement] or raise ArgumentError.new(":statement is 
required")
+      [
+        " #{availid} <#{publicname}>",
+        '',
+        "   Nominee email: #{availid}@apache.org",
+        "   Nominated by: #{nomby}@apache.org",
+        "   Seconded by: #{secby}",
+        '',
+        '   Nomination statement:',
+        statement.split("\n").map do |l|
+          "    #{l}"
+        end
+      ].compact.join("\n") + "\n"
+    end
+
+    # Sort the member_nominees, optionally adding new entries
+    def self.sort_member_nominees(contents, entries=nil)
+      # Find most recent file:
+      sections = contents.split(%r{^-{10,}\n})
+      header = sections.shift(2)
+      sections.append(*entries) if entries # add new entries if any
+      sections.sort_by! do |s|
+        # sort by last name
+        (s[%r{\S+ +<([^>]+)>}, 1] || 'ZZ').split.last
+      end
+      # reconstitute the file
+      [header, sections, 
''].join("-----------------------------------------\n")
+    end
+
+    # update the member nominees
+    def self.update_member_nominees(env, wunderbar, entries=nil, msg=nil)
+      nomfile = latest_meeting('nominated-members.txt')
+      opt = {dryrun: false, verbose: false}
+      ASF::SVN.update(nomfile, msg || 'Updating nominated members', env, 
wunderbar, opt) do |_tmpdir, contents|
+        sort_member_nominees(contents, entries)
+      end
+    end
+
     # TODO: change to return arrays rather than hash.
     # This would help detect duplicate entries
 

Reply via email to