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 3578819 Tool to update list of chairs
3578819 is described below
commit 3578819200b499b858f24f1e7bbadd2eaea6d458
Author: Sebb <[email protected]>
AuthorDate: Fri Mar 22 14:25:29 2019 +0000
Tool to update list of chairs
Currently must be run manually
---
tools/update_chairs.rb | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/tools/update_chairs.rb b/tools/update_chairs.rb
new file mode 100755
index 0000000..5a2ba82
--- /dev/null
+++ b/tools/update_chairs.rb
@@ -0,0 +1,88 @@
+#!/usr/bin/env ruby
+
+# @(#) Script to update foundation/index.txt list of chars from
committee-info.json
+
+# Must be run locally at present, and the changes checked in manually
+
+$LOAD_PATH.unshift '/srv/whimsy/lib'
+
+require 'json'
+require 'open-uri'
+require 'whimsy/asf'
+
+cttees=JSON.parse(open('https://whimsy.apache.org/public/committee-info.json').read)['committees']
+chairs={}
+cttees.reject{|k,v| v['pmc'] == false}.each do|k,v|
+ cttee=v['display_name']
+ chairs[cttee]=v['chair'].first[1]['name']
+end
+
+idx=File.join(ASF::SVN['site-root'],'foundation','index.mdtext')
+
+puts "Updating #{idx} to latest copy"
+puts `svn update #{idx}`
+
+puts "Checking if any changes are needed"
+lines=[]
+first=nil # first line of chairs
+last=nil
+changes=[]
+seen=Hash.new{|h,k| h[k]=0}
+open(idx).each_line do |l|
+# | V.P., Apache Xalan | A. N. Other |
+ m = l.match %r{^\| V.P., \[?Apache (.+?)(\]\(.+?\))? \| (.+?) \|}
+ if m
+ first ||= lines.length
+ last = lines.length
+ name,_,webchair = m.captures
+ cichair = chairs[name]
+ seen[name] += 1
+ unless cichair
+ puts "Cannot find CI entry for #{name}; dropping entry"
+ changes << name
+ next
+ end
+ if seen[name] > 1
+ puts "Duplicate entry for #{name}; dropping"
+ changes << name
+ next
+ end
+ unless webchair == cichair
+ puts "Changing chair for #{name} from #{webchair} to #{cichair}"
+ lines << l.sub(webchair,cichair)
+ changes << name
+ next
+ end
+ end
+ lines << l
+end
+
+notseen = (chairs.keys - seen.keys).sort
+if notseen.length > 0
+ puts "No entry found for: " + notseen.join(',')
+ notseen.each do |e|
+ puts "Adding #{e}"
+ lines.insert last, "| V.P., Apache #{e} | #{chairs[e]} |\n"
+ changes << e
+ end
+ # N.B. Cannot use sort! on slice
+ lines[first..last+notseen.length] =
lines[first..last+notseen.length].sort_by do |l|
+ l.match(/Apache +([^\]|]+)/) do |m|
+ $1.downcase.gsub(' ','')
+ end
+ end
+end
+
+
+if changes.length > 0
+ puts "Updating the file"
+ File.open(idx,"w") do |f|
+ lines.each {|line| f.print line}
+ end
+ puts "#{idx} was updated; check the diffs:"
+ puts `svn diff #{idx}`
+ puts "Copy/paste the next line to commit the change:"
+ puts "svn ci -m'Changed chairs for: #{changes.join(',')}' #{idx}"
+else
+ puts "#{idx} not changed"
+end
\ No newline at end of file