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/09/26 19:35:23 UTC
[whimsy] 03/03: make todos idempotent
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
commit 16dd23d0a4a3deef018171df2ee587bab1075107
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Sep 26 15:35:04 2017 -0400
make todos idempotent
---
lib/whimsy/asf/committee.rb | 13 ++++++---
www/board/agenda/views/actions/todos.json.rb | 42 +++++++++++++++-------------
2 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index 1a06668..f575b28 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -119,23 +119,28 @@ module ASF
block.gsub!(/.* # new, monthly through #{month}\n/, '')
# update/remove existing 'missing' entries
+ existing = []
block.gsub! /(.*?)# missing in .*\n/ do |line|
if missing.include? $1.strip
- missing.delete $1.strip
- "#{line.chomp}, #{month}\n"
+ existing << $1.strip
+ if line.chomp.end_with? month
+ line
+ else
+ "#{line.chomp}, #{month}\n"
+ end
else
''
end
end
# add new 'missing' entries
- missing.each do |pmc|
+ (missing-existing).each do |pmc|
block += " #{pmc.ljust(22)} # missing in #{month}\n"
end
# add new 'established' entries
month = (date+91).strftime('%B')
- establish.each do |pmc|
+ (establish-existing).each do |pmc|
block += " #{pmc.ljust(22)} # new, monthly through #{month}\n"
end
diff --git a/www/board/agenda/views/actions/todos.json.rb b/www/board/agenda/views/actions/todos.json.rb
index 52a2b26..c3e9ccb 100644
--- a/www/board/agenda/views/actions/todos.json.rb
+++ b/www/board/agenda/views/actions/todos.json.rb
@@ -167,38 +167,40 @@ end
if (@change || @establish) and env.password
chairs = ASF::Service.find('pmc-chairs')
+ # select all new chairs
todos = Array(@change) + Array(@establish)
people = todos.map {|todo| ASF::Person.find(todo['chair'])}.uniq
+ people -= chairs.members
- # add new chairs to pmc-chairs
- unless (people-chairs.members).empty?
+ unless people.empty?
+ # add new chairs to pmc-chairs
ASF::LDAP.bind(env.user, env.password) do
chairs.add people-chairs.members
end
- end
- # send out congratulations email
- ASF::Mail.configure
- sender = ASF::Person.new(env.user)
- mail = Mail.new do
- from "#{sender.public_name.inspect} <#{...@apache.org>".untaint
+ # send out congratulations email
+ ASF::Mail.configure
+ sender = ASF::Person.new(env.user)
+ mail = Mail.new do
+ from "#{sender.public_name.inspect} <#{...@apache.org>".untaint
- to people.map {|person|
- "#{person.public_name.inspect} <#{...@apache.org>".untaint
- }.to_a
+ to people.map {|person|
+ "#{person.public_name.inspect} <#{...@apache.org>".untaint
+ }.to_a
- cc 'Apache Board <bo...@apache.org>'
+ cc 'Apache Board <bo...@apache.org>'
- subject "Congratulations on your new role at Apache"
+ subject "Congratulations on your new role at Apache"
- body "Dear new PMC chairs,\n\nCongratulations on your new role at " +
- "Apache. I've changed your LDAP privileges to reflect your new " +
- "status.\n\nPlease read this and update the foundation records:\n" +
- "https://svn.apache.org/repos/private/foundation/officers/advice-for-new-pmc-chairs.txt" +
- "\n\nWarm regards,\n\n#{sender.public_name}"
- end
+ body "Dear new PMC chairs,\n\nCongratulations on your new role at " +
+ "Apache. I've changed your LDAP privileges to reflect your new " +
+ "status.\n\nPlease read this and update the foundation records:\n" +
+ "https://svn.apache.org/repos/private/foundation/officers/advice-for-new-pmc-chairs.txt" +
+ "\n\nWarm regards,\n\n#{sender.public_name}"
+ end
- mail.deliver!
+ mail.deliver!
+ end
end
########################################################################
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.