(whimsy) branch master updated: Simplify
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 a16b5ead Simplify a16b5ead is described below commit a16b5eadfef689a377b702746eb05e871206820a Author: Sebb AuthorDate: Thu Mar 28 23:02:11 2024 + Simplify --- lib/whimsy/asf/svn.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index dea083c8..cd030f58 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -354,11 +354,9 @@ module ASF cmd[0] = 'whimsysvn' # need wrapper for SVN proxy role end unless options[:dryrun] # don't add auth for dryrun -if password or user == 'whimsysvn' # whimsysvn user does not require password - cmd << ['--username', user, '--no-auth-cache'] -end # password was supplied, add credentials if password + cmd << ['--username', user, '--no-auth-cache'] if self.passwordStdinOK?() stdin = password cmd << ['--password-from-stdin']
(whimsy) branch master updated: Simplify
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 6ae6237c Simplify 6ae6237c is described below commit 6ae6237c9f044e1d7b28f14315e48cee2a91f1f1 Author: Sebb AuthorDate: Tue Mar 12 23:38:10 2024 + Simplify --- www/secretary/workbench/views/actions/memapp.json.rb | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/www/secretary/workbench/views/actions/memapp.json.rb b/www/secretary/workbench/views/actions/memapp.json.rb index 803a6b98..7600906f 100644 --- a/www/secretary/workbench/views/actions/memapp.json.rb +++ b/www/secretary/workbench/views/actions/memapp.json.rb @@ -163,16 +163,10 @@ end # TODO combine with other SVN updates task "svn commit memapp-received.text" do - meetings = ASF::SVN['Meetings'] - file = Dir["#{meetings}/2*/memapp-received.txt"].max + file = ASF::MeetingUtil.get_latest_file('memapp-received.txt') received = File.read(file) - if received =~ /^no\s+\w+\s+\w+\s+\w+\s+#{@availid}\s/ -received[/^(no )\s+\w+\s+\w+\s+\w+\s+#{@availid}\s/,1] = 'yes' - end - received[/(no )\s+\w+\s+\w+\s+#{@availid}\s/,1] = 'yes' - received[/(no )\s+\w+\s+#{@availid}\s/,1] = 'yes' - received[/(no )\s+#{@availid}\s/,1] = 'yes' - @line = received[/.*\s#{@availid}\s.*/] + original = received[/.*\s#{@availid}\s.*/] + @line = original.gsub('no ','yes') form do _input value: @line, name: 'line' @@ -182,7 +176,7 @@ task "svn commit memapp-received.text" do meeting = file.split('/')[-2] path = ASF::SVN.svnpath!('Meetings', meeting,'memapp-received.txt') rc = ASF::SVN.update(path, @document, env, _, {diff: true}) do |_tmpdir, input| - input[/.*\s#{@availid}\s.*/] = @line + input.sub!(original, @line) input end raise RuntimeError.new("exit code: #{rc}") if rc != 0
(whimsy) branch master updated: Simplify
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 a33ca196 Simplify a33ca196 is described below commit a33ca196513865f34f42fac3a0ed707c3676e900 Author: Sebb AuthorDate: Tue Feb 13 17:50:13 2024 + Simplify --- www/members/board-nominations.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/members/board-nominations.cgi b/www/members/board-nominations.cgi index 7c932829..5786939e 100755 --- a/www/members/board-nominations.cgi +++ b/www/members/board-nominations.cgi @@ -8,7 +8,7 @@ require 'wunderbar/bootstrap' require 'whimsy/asf' require 'whimsy/asf/member-files' require 'whimsy/asf/meeting-util' -require '../tools/parsemail' +require_relative '../../tools/parsemail' # link to members private-arch MBOX = 'https://mail-search.apache.org/members/private-arch/members/' @@ -118,7 +118,7 @@ _html do _li! do person = ASF::Person.find(nominee[:id]) - if emails.any? {|mail| ASF::Person.asciize(mail.subject.downcase.delete('.'), nil) =~ nominee[:match]} + if emails.any? {|mail| mail[:asciiname] =~ nominee[:match]} _a.present person.public_name || '??', href: "#{ROSTER}/#{nominee[:id]}" else _a.missing person.public_name || '??', href: "#{ROSTER}/#{nominee[:id]}"
(whimsy) branch master updated: Simplify and re-organise code for easier testing
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 f9501e19 Simplify and re-organise code for easier testing f9501e19 is described below commit f9501e191199c5e13d717e200a6ad38ec1763b59 Author: Sebb AuthorDate: Mon Feb 12 15:53:26 2024 + Simplify and re-organise code for easier testing --- .../views/actions/check-signature.json.rb | 110 + 1 file changed, 69 insertions(+), 41 deletions(-) diff --git a/www/secretary/workbench/views/actions/check-signature.json.rb b/www/secretary/workbench/views/actions/check-signature.json.rb index 41437df2..37d44568 100644 --- a/www/secretary/workbench/views/actions/check-signature.json.rb +++ b/www/secretary/workbench/views/actions/check-signature.json.rb @@ -1,17 +1,25 @@ # frozen_string_literal: true require 'uri' +require 'net/http' + +MAX_KEY_SIZE = 125000 # don't import if the ascii keyfile is larger than this # check signature on an attachment # +if $0 == __FILE__ + require 'wunderbar' + $LOAD_PATH.unshift '/srv/whimsy/lib' + require 'whimsy/asf' + require_relative '../../models/mailbox' +end + ENV['GNUPGHOME'] = GNUPGHOME if GNUPGHOME # see WHIMSY-274 for secure servers # ** N.B. ensure the keyserver URI is known below ** -# Restored keys.openpgp.org; sks-keryservers is dead; we can do without email -# gozer.rediris.es certificate has expired KEYSERVERS = %w{keyserver.ubuntu.com} # openpgp does not return the uid needed by gpg @@ -33,10 +41,6 @@ def getServerURI(server, keyid) return uri end -MAX_KEY_SIZE = 125000 # don't import if the ascii keyfile is larger than this - -require 'net/http' - # fetch the Key from the URI and store in the file def getURI(uri, file) uri = URI.parse(uri) @@ -71,13 +75,7 @@ def getURI(uri, file) end end -message = Mailbox.find(@message) - -begin - # fetch attachment and signature - attachment = message.find(URI::RFC2396_Parser.new.unescape(@attachment)).as_file # This is derived from a URI - signature = message.find(@signature).as_file # This is derived from the YAML file - +def validate_sig(attachment, signature) # pick the latest gpg version gpg = `which gpg2`.chomp gpg = `which gpg`.chomp if gpg.empty? @@ -97,40 +95,37 @@ begin # extract and fetch key keyid = err[/[RD]SA key (ID )?(\w+)/,2] -out2 = err2 = '' # needed later - # Try to fetch the key -KEYSERVERS.each do |server| +Dir.mktmpdir do |dir| found = false - Dir.mktmpdir do |dir| + tmpfile = File.join(dir, keyid) + KEYSERVERS.each do |server| begin - tmpfile = File.join(dir, keyid) - uri = getServerURI(server, keyid) - getURI(uri, tmpfile) - out2, err2, rc2 = Open3.capture3 gpg, + # uri = getServerURI(server, keyid) + # get the public key if possible (throws if not) + # getURI(uri, tmpfile) + FileUtils.cp(File.join('/srv/whimsy', keyid), tmpfile) # Temp, don't bother gpg database + # import the key for use in validation + out, err, rc = Open3.capture3 gpg, '--batch', '--import', tmpfile # For later analysis - Wunderbar.warn "#{gpg} --import #{tmpfile} rc2=#{rc2} out2=#{out2} err2=#{err2}" + Wunderbar.warn "#{gpg} --import #{tmpfile} rc=#{rc} out=#{out} err=#{err}" found = true rescue Exception => e Wunderbar.warn "GET uri=#{uri} e=#{e}" - err2 = e.to_s + err = "Key #{keyid} not found: #{e.to_s}".dup # Dup needed to unfreeze string for later end +break if found + end + if found + +# run gpg verify command again +# TODO: may need to drop the keyid-format parameter when gpg is updated as it might +# reduce the keyid length from the full fingerprint +out, err, rc = Open3.capture3 gpg, + '--keyid-format', 'long', # Show a longer id + '--verify', signature.path, attachment.path end - break if found -end - -# run gpg verify command again -# TODO: may need to drop the keyid-format parameter when gpg is updated as it might -# reduce the keyid length from the full fingerprint -out, err, rc = Open3.capture3 gpg, - '--keyid-format', 'long', # Show a longer id - '--verify', signature.path, attachment.path - -# if verify failed, concatenate fetch output -if rc.exitstatus != 0 - out += out2 - err += err2 end end @@ -146,9 +141,42 @@ begin ignore.each {|re| err.gsub! re, ''} -ensure - attachment.unlink if attachment - signature.unlink if signature + return out, err, rc +end + +def process + message = Mailbox.find(@message) # e.g. /secretary/workbench/mm/123456789a/ + + begin +# fetch
(whimsy) branch master updated: Simplify
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 1c6cd1c7 Simplify 1c6cd1c7 is described below commit 1c6cd1c772f1180db8398a9c24e925823078cfba Author: Sebb AuthorDate: Thu Feb 8 17:18:58 2024 + Simplify --- www/members/proxy.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/members/proxy.cgi b/www/members/proxy.cgi index 25020700..3a351914 100755 --- a/www/members/proxy.cgi +++ b/www/members/proxy.cgi @@ -87,7 +87,7 @@ def emit_form(cur_mtg_dir, meeting, volunteers, disabled) return end begin -secretary_id = ASF::Committee.officers.select{|x|x.name == 'secretary'}.first.chairs.map{|x|x[:id]}.first +secretary_id = ASF::Committee.officer('secretary').id rescue StandardError secretary_id = '' end @@ -185,6 +185,8 @@ def emit_form(cur_mtg_dir, meeting, volunteers, disabled) $('*[name="proxy"]').change(function() { $('.btn').prop('disabled', false); }); + + $('.combobox').on } end
(whimsy) branch master updated: Simplify Mustache rendering
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 13428d25 Simplify Mustache rendering 13428d25 is described below commit 13428d25741e79563aa40bb9b067ed22163927f4 Author: Sebb AuthorDate: Fri Jan 5 23:04:42 2024 + Simplify Mustache rendering --- www/board/agenda/helpers/mustache-template.rb | 55 ++ www/board/agenda/main.rb | 1 + .../agenda/views/actions/reminder-text.json.rb | 11 + 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/www/board/agenda/helpers/mustache-template.rb b/www/board/agenda/helpers/mustache-template.rb new file mode 100644 index ..dd61eb24 --- /dev/null +++ b/www/board/agenda/helpers/mustache-template.rb @@ -0,0 +1,55 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if __FILE__ == $0 # This is normally done by main.rb + require 'mustache' + FOUNDATION_BOARD = '/srv/svn/foundation_board' +end + +# simplify processing of Agenda Mustache templates +# params: +# template - the prefix name, e.g. reminder1 +# context - the variable values to be used +# raise_on_context_miss - raise an Exception if any variables are missing [default true] +# returns: {subject: subject, body: body} +class AgendaTemplate + def self.render(template, context, raise_on_context_miss=false) +unless template =~ /\A[-\w]+\z/ + raise ArgumentError.new("Invalid template name #{template}") +end +m = Mustache.new +m.template_file = File.join(FOUNDATION_BOARD, 'templates', template+'.mustache') +m.raise_on_context_miss = raise_on_context_miss +template = m.render(context) +# extract subject +subject = template[/Subject: (.*)/, 1] +template[/Subject: .*\s+/] = '' + +# return results +{subject: subject, body: template} + end +end + +if __FILE__ == $0 + sent_emails = [] + sent_emails << {name: 'a', emails: 'c, d'} + sent_emails << {name: 'a', emails: 'c, d'} + sent_emails << {name: 'a', emails: 'c, d'} + sent_emails << {name: 'a', emails: 'c, d'} + view = {meeting: 'meeting', agenda: 'board_agenda_2024_01_17.txt', unsent: ['a', 'b', 'c'], sent_emails: sent_emails} + render = AgendaTemplate.render('reminder-summary',view, true) + puts render[:subject] + puts render[:body] +end diff --git a/www/board/agenda/main.rb b/www/board/agenda/main.rb index 83086903..fbc8c7d4 100755 --- a/www/board/agenda/main.rb +++ b/www/board/agenda/main.rb @@ -55,6 +55,7 @@ require_relative './models/agenda' require_relative './models/minutes' require_relative './models/comments' require_relative './models/reporter' +require_relative './helpers/mustache-template' require_relative './helpers/string' require_relative './helpers/integer' require_relative './daemon/session' diff --git a/www/board/agenda/views/actions/reminder-text.json.rb b/www/board/agenda/views/actions/reminder-text.json.rb index b7e87a08..0a99db58 100644 --- a/www/board/agenda/views/actions/reminder-text.json.rb +++ b/www/board/agenda/views/actions/reminder-text.json.rb @@ -3,8 +3,6 @@ require 'active_support/time' raise ArgumentError, "Invalid syntax #{@reminder}" unless @reminder =~ /\A[-\w]+\z/ -# read template for the reminders -template = File.read(File.join(FOUNDATION_BOARD, 'templates', "#{@reminder}.mustache")) # Allow override of timeZoneInfo (avoids the need to parse the last agenda) timeZoneInfo = @tzlink @@ -32,11 +30,4 @@ view = { } # perform the substitution -template = Mustache.render(template, view) - -# extract subject -subject = template[/Subject: (.*)/, 1] -template[/Subject: .*\s+/] = '' - -# return results -{subject: subject, body: template} +AgendaTemplate.render(@reminder, view)
[whimsy] branch master updated: Simplify - only need to set field if true
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 cd62a730 Simplify - only need to set field if true cd62a730 is described below commit cd62a7307ba1378322c6ba1cbd53996d16ed2c9a Author: Sebb AuthorDate: Sun Apr 23 17:01:28 2023 +0100 Simplify - only need to set field if true --- www/roster/models/committee.rb| 4 ++-- www/roster/models/nonpmc.rb | 2 +- www/roster/models/ppmc.rb | 14 ++ www/roster/views/nonpmc/members.js.rb | 4 ++-- www/roster/views/pmc/members.js.rb| 4 ++-- www/roster/views/ppmc/members.js.rb | 4 ++-- www/roster/views/ppmc/mentors.js.rb | 4 ++-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/www/roster/models/committee.rb b/www/roster/models/committee.rb index b7c0e875..35b9aaaf 100644 --- a/www/roster/models/committee.rb +++ b/www/roster/models/committee.rb @@ -60,7 +60,7 @@ class Committee allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)} # pSubs is already downcased # TODO should it be canonicalised as well above? -roster[key]['notSubbed'] = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? +roster[key]['notSubbed'] = true if (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} unMatchedSecSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} end @@ -77,7 +77,7 @@ class Committee allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)} # pSubs is already downcased # TODO should it be canonicalised as well above? -roster[person.id]['notSubbed'] = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? +roster[person.id]['notSubbed'] = true if (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} unMatchedSecSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} end diff --git a/www/roster/models/nonpmc.rb b/www/roster/models/nonpmc.rb index c19fc678..06137c4b 100644 --- a/www/roster/models/nonpmc.rb +++ b/www/roster/models/nonpmc.rb @@ -68,7 +68,7 @@ class NonPMC } if analysePrivateSubs allMail = person.all_mail.map(&:downcase) -roster[person.id]['notSubbed'] = (allMail & pSubs).empty? +roster[person.id]['notSubbed'] = true if (allMail & pSubs).empty? unMatchedSubs.delete_if {|k| allMail.include? k.downcase} unMatchedSecSubs.delete_if {|k| allMail.include? k.downcase} end diff --git a/www/roster/models/ppmc.rb b/www/roster/models/ppmc.rb index e9a9c938..7b4ce67a 100644 --- a/www/roster/models/ppmc.rb +++ b/www/roster/models/ppmc.rb @@ -64,20 +64,18 @@ class PPMC # Merge the PPMC members (owners) owners.each do |person| - notSubbed = false - if analysePrivateSubs -allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)} -notSubbed = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? -unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} - end roster[person.id] = { -notSubbed: notSubbed, name: person.public_name, member: person.asf_member?, icommit: incubator_committers.include?(person), role: 'PPMC Member', githubUsername: (person.attrs['githubUsername'] || []).join(', ') } + if analysePrivateSubs +allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)} +roster[person.id]['notSubbed'] = true if (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? +unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} + end end # Finally merge the mentors @@ -93,7 +91,7 @@ class PPMC } if analysePrivateSubs allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)} -roster[person.id]['notSubbed'] = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? +roster[person.id]['notSubbed'] = true if (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty? unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)} end end diff --git a/www/roster/views/nonpmc/members.js.rb b/www/roster/views/nonpmc/members.js.rb index 90b9c122..f16bf5ef 100644 --- a/www/roster/views/nonpmc/members.js.rb +++ b/www/roster/views/nonpmc/members.js.rb @@ -72,13 +72,13 @@ class NonPMCMember < Vue end if @@person.member _td { _b { _a @@person.id, href: "committer/#{@@person.id}" } - _a ' (*)',
[whimsy] branch master updated: Simplify - Wunderbar handles parms etc for us
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 eb7009f8 Simplify - Wunderbar handles parms etc for us eb7009f8 is described below commit eb7009f86082ba0ea7845d2122f213386574555c Author: Sebb AuthorDate: Tue Apr 18 23:35:58 2023 +0100 Simplify - Wunderbar handles parms etc for us --- www/secretary/upload_file.cgi | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/www/secretary/upload_file.cgi b/www/secretary/upload_file.cgi index 213d9aa8..1bac1d66 100755 --- a/www/secretary/upload_file.cgi +++ b/www/secretary/upload_file.cgi @@ -21,7 +21,7 @@ _html do } ) do _whimsy_panel('Upload a new file to SVN', style: 'panel-success') do -_form.form_horizontal action: 'upload_file.cgi', method: 'post', enctype: "multipart/form-data" do +_form.form_horizontal method: 'post', enctype: "multipart/form-data" do _div.form_group do _label.control_label.col_sm_2 'SVN path', for: 'url' _div.col_sm_10 do @@ -49,27 +49,24 @@ _html do end _div.well.well_lg do if _.post? - # params are arrays - url = params['url'].first - if url !~ %r{^https://(dist|svn)\.apache\.org/\S+$} + if @url !~ %r{^https://(dist|svn)\.apache\.org/\S+$} raise ArgumentError.new("Invalid SVN URL!") end - source = params['source'].first - msg = "Uploaded by Whimsy: #{params['msg'].first.strip}" + msg = "Uploaded by Whimsy: #{@msg}" # The source is StringIO for smaller files, Tempfile for larger ones # The cutoff seems to be somewhere between 18k and 27k - if source.instance_of? Tempfile -data = source + if @source.instance_of? Tempfile +data = @source else -data = source.read +data = @source.read end - name = source.original_filename.gsub(/[^-.\w]/, '_').sub(/^\.+/, '_') + name = @source.original_filename.gsub(/[^-.\w]/, '_').sub(/^\.+/, '_') ASF::Auth.decode(env = {}) # data can either be a string or a Tempfile - if ASF::SVN.create_(url, name, data, msg, env, _) == 0 -_p "Successfully added #{name} to #{url} !" + if ASF::SVN.create_(@url, name, data, msg, env, _) == 0 +_p "Successfully added #{name} to #{@url} !" else -_p "File #{name} already exists at #{url} ?" +_p "File #{name} already exists at #{@url} ?" end end end
[whimsy] branch master updated: Simplify
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 9080f84e Simplify 9080f84e is described below commit 9080f84e91cff0c3bb97c3becfae11e53ac7247d Author: Sebb AuthorDate: Wed Mar 1 11:16:47 2023 + Simplify --- tools/collate_minutes.rb | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/collate_minutes.rb b/tools/collate_minutes.rb index 04606926..e92d72ec 100755 --- a/tools/collate_minutes.rb +++ b/tools/collate_minutes.rb @@ -326,7 +326,7 @@ seen={} next if text.strip.empty? and title =~ /Intentionally (left )?Blank/i next if text.strip.empty? and title =~ /There is No/i -report = pending[attach] || OpenStruct.new +report = pending[attach] ||= OpenStruct.new report.meeting = date report.attach = attach report.owners ||= owners if owners @@ -353,8 +353,6 @@ seen={} report.attach = '@' + attach end -pending[attach] = report - if title == 'Incubator' and text sections = text.split(/\nStatus [rR]eport (.*)\n=+\n/) # Some minutes have a 'Detailed Reports' header before the first podling report @@ -433,12 +431,11 @@ seen={} (.*?)\n # comments \s\s\s\s?\w # separator /mx).each do |owners,attach,comments| -report = pending[attach] || OpenStruct.new +report = pending[attach] ||= OpenStruct.new report.meeting = date report.attach = attach report.owners = owners report.comments = comments.strip -pending[attach] = report end # fill in comments from missing reports @@ -455,12 +452,11 @@ seen={} # TODO: This does not work properly attach = ('A'..attach).count.to_s if section == 'Additional Officer' - report = pending[attach] || OpenStruct.new + report = pending[attach] ||= OpenStruct.new report.meeting = date report.attach = attach report.owners = owners report.comments = comments.strip - pending[attach] = report end end
[whimsy] branch master updated: Simplify - use common library method
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 a3c20581 Simplify - use common library method a3c20581 is described below commit a3c20581a4e6ed3b722dcd31d8a03103b359dbed Author: Sebb AuthorDate: Wed Feb 8 17:14:05 2023 + Simplify - use common library method --- lib/whimsy/asf/rack.rb | 3 +-- www/roster/main.rb | 2 +- www/roster/views/index.html.rb | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/whimsy/asf/rack.rb b/lib/whimsy/asf/rack.rb index 9027300e..107842f6 100644 --- a/lib/whimsy/asf/rack.rb +++ b/lib/whimsy/asf/rack.rb @@ -75,8 +75,7 @@ module ASF person = ASF::Auth.decode(env) -authorized ||= person.asf_member? -authorized ||= ASF.pmc_chairs.include? person +authorized ||= person.asf_chair_or_member? authorized ||= @block.call(env) if @block if authorized diff --git a/www/roster/main.rb b/www/roster/main.rb index 31ac919c..1354b440 100755 --- a/www/roster/main.rb +++ b/www/roster/main.rb @@ -411,7 +411,7 @@ end get '/orgchart/:name' do |name| person = ASF::Person.find(env.user) - unless person.asf_member? or ASF.pmc_chairs.include? person + unless person.asf_chair_or_member? halt 401, "Not authorized\n" end diff --git a/www/roster/views/index.html.rb b/www/roster/views/index.html.rb index 86d62ac7..b091e00a 100644 --- a/www/roster/views/index.html.rb +++ b/www/roster/views/index.html.rb @@ -48,7 +48,7 @@ _html do end end -if person.asf_member? or ASF.pmc_chairs.include? person +if person.asf_chair_or_member? _tr do _td do _a @committers.length, href: 'committer2/' @@ -166,7 +166,7 @@ _html do end - if person.asf_member? or ASF.pmc_chairs.include? person + if person.asf_chair_or_member? _hr _p do _a 'Search pending ICLAs', href: 'icla/'
[whimsy] branch master updated: Simplify - use common library method
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 c515c17d Simplify - use common library method c515c17d is described below commit c515c17d38b9b817b223750c0261b58326a8306b Author: Sebb AuthorDate: Wed Feb 8 16:55:35 2023 + Simplify - use common library method --- www/board/agenda/models/reporter.rb | 2 +- www/board/agenda/routes.rb | 4 ++-- www/board/agenda/views/actions/post.json.rb | 2 +- www/board/agenda/views/actions/reporter.json.rb | 2 +- www/fundraising/invoice.cgi | 2 +- www/officers/acreq.cgi | 2 +- www/officers/list-traffic.cgi | 2 +- www/officers/unlistedclas.cgi | 2 +- www/secretary/public-names.cgi | 2 +- www/secretary/response-time.cgi | 2 +- www/treasurer/bill-upload.cgi | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/www/board/agenda/models/reporter.rb b/www/board/agenda/models/reporter.rb index 4bcd2ad9..93a74bee 100644 --- a/www/board/agenda/models/reporter.rb +++ b/www/board/agenda/models/reporter.rb @@ -91,7 +91,7 @@ class Reporter # filter drafts based on user visibility user = env.respond_to?(:user) && ASF::Person.find(env.user) -unless !user or user.asf_member? or ASF.pmc_chairs.include? user +unless !user or user.asf_chair_or_member? projects = user.committees.map(&:name) results[:drafts].keep_if do |attach, draft| projects.include? draft[:project] diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb index 2e524e23..94dd81f2 100755 --- a/www/board/agenda/routes.rb +++ b/www/board/agenda/routes.rb @@ -389,7 +389,7 @@ get %r{/(\d\d\d\d-\d\d-\d\d).json} do |date| # filter list for non-PMC chairs and non-officers user = env.respond_to?(:user) && ASF::Person.find(env.user) - unless !user or user.asf_member? or ASF.pmc_chairs.include? user + unless !user or user.asf_chair_or_member? status 206 # Partial Content committees = user.committees.map(&:display_name) agenda = agenda.select {|item| committees.include? item['title']} @@ -489,7 +489,7 @@ get '/json/historical-comments' do user = env.respond_to?(:user) && ASF::Person.find(env.user) comments = HistoricalComments.comments - unless !user or user.asf_member? or ASF.pmc_chairs.include? user + unless !user or user.asf_chair_or_member? status 206 # Partial Content committees = user.committees.map(&:display_name) comments = comments.select do |project, _list| diff --git a/www/board/agenda/views/actions/post.json.rb b/www/board/agenda/views/actions/post.json.rb index d9773b8c..2facd850 100644 --- a/www/board/agenda/views/actions/post.json.rb +++ b/www/board/agenda/views/actions/post.json.rb @@ -18,7 +18,7 @@ attach = nil # Determine if user is authorized user = ASF::Person.find(env.user) -member_or_officer = (user.asf_member? or ASF.pmc_chairs.include? user) +member_or_officer = (user.asf_chair_or_member?) real_web_server = env.password alternate_credentials = (real_web_server and not member_or_officer) ? [['--username', 'whimsysvn']] : nil diff --git a/www/board/agenda/views/actions/reporter.json.rb b/www/board/agenda/views/actions/reporter.json.rb index e7f7c63a..447cf84a 100644 --- a/www/board/agenda/views/actions/reporter.json.rb +++ b/www/board/agenda/views/actions/reporter.json.rb @@ -1,7 +1,7 @@ # ASF members and PMC chairs can post anything, everybody else can only post # to updates for the PMCs that they belong to. user = env.respond_to?(:user) && ASF::Person.find(env.user) -unless !user or user.asf_member? or ASF.pmc_chairs.include? user +unless !user or user.asf_chair_or_member? projects = user.committees.map(&:name) @report_status.each do |project, status| unless projects.include? project diff --git a/www/fundraising/invoice.cgi b/www/fundraising/invoice.cgi index 46b41eb5..335d64ed 100755 --- a/www/fundraising/invoice.cgi +++ b/www/fundraising/invoice.cgi @@ -7,7 +7,7 @@ require "yaml" require 'whimsy/asf' user = ASF::Person.new($USER) -unless user.asf_member? or ASF.pmc_chairs.include? user +unless user.asf_chair_or_member? print "Status: 401 Unauthorized\r\n" print "WWW-Authenticate: Basic realm=\"ASF Members and Officers\"\r\n\r\n" exit diff --git a/www/officers/acreq.cgi b/www/officers/acreq.cgi index d5b05f2c..f6df1cb8 100755 --- a/www/officers/acreq.cgi +++ b/www/officers/acreq.cgi @@ -10,7 +10,7 @@ require 'mail' require 'date' user = ASF::Auth.decode(env = {}) -unless user.asf_member? or ASF.pmc_chairs.include? user +unless user.asf_chair_or_member? print "Status: 401 Unauthorized\r\n" print "WWW-Authenticate: Basic realm=\"ASF
[whimsy] branch master updated: simplify label
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 be191c95 simplify label be191c95 is described below commit be191c9544653da81d356c7ad60d891b8eb673d7 Author: Sam Ruby AuthorDate: Tue May 31 20:58:46 2022 -0400 simplify label --- www/project/icla2/views/form.erb | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/project/icla2/views/form.erb b/www/project/icla2/views/form.erb index 16c9dcea..0668f79d 100644 --- a/www/project/icla2/views/form.erb +++ b/www/project/icla2/views/form.erb @@ -6,8 +6,10 @@ - What is your name? - + What is your name? + + +
[whimsy] branch master updated: Simplify 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 c0dac2d Simplify code c0dac2d is described below commit c0dac2df01c1ce94deb819d9057e69fc449d53be Author: Sebb AuthorDate: Fri Mar 25 09:22:23 2022 + Simplify code --- www/board/agenda/views/router.js.rb | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/board/agenda/views/router.js.rb b/www/board/agenda/views/router.js.rb index 72123d5..c9fbeaa 100644 --- a/www/board/agenda/views/router.js.rb +++ b/www/board/agenda/views/router.js.rb @@ -105,7 +105,7 @@ class Router item = nil Agenda.index.each do |i| if i.attach =~ /^8[.A-Z]/ - item = i unless item + item ||= i end end @@ -128,7 +128,7 @@ class Router # provide defaults for required properties item.color ||= 'blank' -if not item.title +unless item.title item.title = item.view.options.name. gsub(/(^|-)\w/) {|c| return c.upcase()}. gsub('-', ' ').strip() @@ -144,11 +144,11 @@ class Router # form overrides form = button.form -if form and form.button +if form&.button form.button.each_pair do |name, override| if name == 'text' props.text = form.button.text -elsif name == 'class' or name == 'classname' +elsif %w{class classname}.include? name props.attrs.class += " #{override.gsub('_', '-')}" else props.attrs[name.gsub('_', '-')] = override @@ -165,7 +165,7 @@ class Router button.each_pair do |name, override| if name == 'text' props.text = button.text - elsif name == 'class' or name == 'classname' + elsif %w{class classname}.include? name props.attrs.class += " #{override.gsub('_', '-')}" elsif name != 'form' props.attrs[name.gsub('_', '-')] = override
[whimsy] branch master updated: Simplify code check
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 1e56ea8 Simplify code check 1e56ea8 is described below commit 1e56ea86214f8321f6b36e30b29cc8848b079854 Author: Sebb AuthorDate: Fri Nov 12 17:40:11 2021 + Simplify code check --- tools/download_check.rb | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/download_check.rb b/tools/download_check.rb index 0901bea..98dbba2 100755 --- a/tools/download_check.rb +++ b/tools/download_check.rb @@ -171,10 +171,10 @@ def fetch_url(url, method=:head, depth=0, followRedirects=true) # string input end end -# Head an HTTP URL => response +# Head an HTTP URL => uri, code, response def HEAD(url) puts ">> HEAD #{url}" if $VERBOSE - fetch_url(url, :head)[2] + fetch_url(url, :head) end # get an HTTP URL => response @@ -185,12 +185,10 @@ end # Check page exists => response or nil def check_head(path, severity = :E, log=true) - response = HEAD(path) - code = (response.code || '?') rescue response.to_s + _uri, code, response = HEAD(path) if code == '403' # someone does not like Whimsy? W "HEAD #{path} - HTTP status: #{code} - retry" -response = HEAD(path) -code = (response.code || '?') rescue response.to_s +_uri, code, response = HEAD(path) end unless code == '200' test(severity, "HEAD #{path} - HTTP status: #{code}") unless severity.nil?
[whimsy] branch master updated: Simplify; no need fo whimsy gem here
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 bb33a54 Simplify; no need fo whimsy gem here bb33a54 is described below commit bb33a541e9004a00c5e4a1cad0859a1306ac0db5 Author: Sebb AuthorDate: Sat Aug 7 23:32:15 2021 +0100 Simplify; no need fo whimsy gem here --- lib/Gemfile | 2 -- lib/spec/spec_helper.rb | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Gemfile b/lib/Gemfile index 6fd3ef8..bc81476 100644 --- a/lib/Gemfile +++ b/lib/Gemfile @@ -1,6 +1,5 @@ source 'https://rubygems.org' -root = '../..' # lib needs these at run-time gem 'json' gem 'nokogiri' @@ -11,6 +10,5 @@ gem 'pdf-reader' # For Travis testing group :test do - gem 'whimsy-asf', path: File.expand_path('..', __dir__) gem 'rspec' end diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb index 44009d5..634d8c3 100644 --- a/lib/spec/spec_helper.rb +++ b/lib/spec/spec_helper.rb @@ -1,4 +1,6 @@ -$LOAD_PATH.unshift '/srv/whimsy/lib' +# Use relative paths for CI such as Travis +lib = File.expand_path('..', __dir__) +$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib require 'whimsy/asf' require 'whimsy/asf/config' # must be loaded before updating config
[whimsy] branch master updated: Simplify: move docker to top level
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 d04a9cd Simplify: move docker to top level d04a9cd is described below commit d04a9cd9135052c67bac73eed9f0ce1e112653bc Author: Sebb AuthorDate: Wed Jul 28 13:38:56 2021 +0100 Simplify: move docker to top level --- .dockerignore | 6 docker/Dockerfile => Dockerfile | 5 ++-- Rakefile | 34 +-- docker/docker-compose.yaml => docker-compose.yaml | 2 +- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000..512e8ef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# Ignore everything initially +** + +# Allow what we want +!config/whimsy.conf +!config/25-authz_ldap_group_membership.conf diff --git a/docker/Dockerfile b/Dockerfile similarity index 90% rename from docker/Dockerfile rename to Dockerfile index f42e4e1..9939573 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -65,8 +65,9 @@ RUN DEBIAN_FRONTEND='noninteractive' apt-get install -y ldap-utils # This should be last, as the source is likely to change # It also takes very little time, so it does not matter if it has to be redone -COPY work/whimsy.conf /etc/apache2/sites-enabled/000-default.conf -COPY work/25-authz_ldap_group_membership.conf /etc/apache2/conf-enabled/25-authz_ldap_group_membership.conf +# N.B. These files need to be allowed in the .dockerignore file +COPY config/whimsy.conf /etc/apache2/sites-enabled/000-default.conf +COPY config/25-authz_ldap_group_membership.conf /etc/apache2/conf-enabled/25-authz_ldap_group_membership.conf WORKDIR /srv/whimsy EXPOSE 80 diff --git a/Rakefile b/Rakefile index a533dea..0bd383f 100644 --- a/Rakefile +++ b/Rakefile @@ -372,30 +372,22 @@ end # Docker support namespace :docker do - task :build => ['docker/work/whimsy.conf', 'docker/work/25-authz_ldap_group_membership.conf'] do -Dir.chdir File.join(__dir__, 'docker') do - sh 'docker-compose build web' # name 'web' must agree with services entry in docker-compose.yaml -end + task :build do +sh 'docker-compose build web' # name 'web' must agree with services entry in docker-compose.yaml end task :update => :build do -Dir.chdir File.join(__dir__, 'docker') do - sh 'docker-compose run --entrypoint ' + -%('bash -c "rake docker:scaffold && rake update"') + -' web' -end +sh 'docker-compose run --entrypoint ' + + %('bash -c "rake docker:scaffold && rake update"') + + ' web' end task :up do -Dir.chdir File.join(__dir__, 'docker') do - sh 'docker-compose up' -end +sh 'docker-compose up' end task :exec do -Dir.chdir File.join(__dir__, 'docker') do - sh 'docker-compose exec web /bin/bash' -end +sh 'docker-compose exec web /bin/bash' end # cannot depend on :config @@ -452,15 +444,3 @@ namespace :docker do sh 'apache2ctl -DFOREGROUND' end end - -file 'docker/work' do - mkdir_p 'docker/work' -end - -file 'docker/work/whimsy.conf' => ['docker/work', 'config/whimsy.conf'] do - cp 'config/whimsy.conf', 'docker/work/whimsy.conf' -end - -file 'docker/work/25-authz_ldap_group_membership.conf' => ['docker/work', 'config/25-authz_ldap_group_membership.conf'] do - cp 'config/25-authz_ldap_group_membership.conf', 'docker/work/25-authz_ldap_group_membership.conf' -end diff --git a/docker/docker-compose.yaml b/docker-compose.yaml similarity index 93% rename from docker/docker-compose.yaml rename to docker-compose.yaml index ed405ff..1602382 100644 --- a/docker/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,7 +8,7 @@ services: environment: - "HOST_HOME=$HOME" volumes: - - ../..:/srv + - ..:/srv - $HOME/.subversion:/$HOME/.subversion - $HOME/.gitconfig:/$HOME/.gitconfig - $HOME/.ssh:/$HOME/.ssh
[whimsy] branch master updated: Simplify; add doc note
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 cf561d9 Simplify; add doc note cf561d9 is described below commit cf561d92e7b3943b17e9d78bd4c5f5482628360d Author: Sebb AuthorDate: Mon Jul 26 23:44:57 2021 +0100 Simplify; add doc note --- lib/whimsy/asf/person.rb | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/whimsy/asf/person.rb b/lib/whimsy/asf/person.rb index 49508cd..871b735 100644 --- a/lib/whimsy/asf/person.rb +++ b/lib/whimsy/asf/person.rb @@ -167,18 +167,21 @@ module ASF # extract sn and givenName from cn (needed for LDAP entries) # returns sn, [givenName,...] +# Note that givenName is returned as an array (may be empty). +# This is because givenName is an optional attribute which may appear multiple times. +# It remains to be seen whether we want to create multiple attributes, +# or whether it is more appropriate to add at most one attribute +# containing all the givenName values. [The array can be joined to produce a single value]. # DRAFT version: not for general use yet # Does not handle multi-word family names or honorifics etc def self.ldap_parse_cn_DRAFT(cn, familyFirst) words = cn.split(' ') if familyFirst sn = words.shift -givenName = words else sn = words.pop -givenName = words end - return sn, givenName + return sn, words end # Name equivalences
[whimsy] branch master updated: Simplify
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 6f52f6c Simplify 6f52f6c is described below commit 6f52f6ce451cfbf032c833d5adb1938a6f968a6b Author: Sebb AuthorDate: Sun Feb 28 15:18:31 2021 + Simplify --- lib/whimsy/asf/member-files.rb | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/whimsy/asf/member-files.rb b/lib/whimsy/asf/member-files.rb index 8e30f67..dce855f 100644 --- a/lib/whimsy/asf/member-files.rb +++ b/lib/whimsy/asf/member-files.rb @@ -32,7 +32,7 @@ module ASF # automatically transcode strings, so we do it here. # This is necessary to avoid issues with matching Regexes. File.open(nomfile, mode='rb:UTF-8') -.map{|l| l.encode('utf-8', invalid: :replace)} +.map(&:scrub) .slice_before(/^\s*---+--\s*/) .drop(2) # instructions and sample block .each do |block| @@ -90,7 +90,17 @@ module ASF end if __FILE__ == $0 - ASF::MemberFiles.member_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name']&.encoding]} + ASF::MemberFiles.member_nominees.each do |k,v| +p [k, + v['Public Name'], + v['Public Name']&.encoding, + v['Public Name']&.valid_encoding?] + end puts "--" - ASF::MemberFiles.board_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name']&.encoding]} + ASF::MemberFiles.board_nominees.each do |k,v| +p [k, + v['Public Name'], + v['Public Name']&.encoding, + v['Public Name']&.valid_encoding?] + end end \ No newline at end of file
[whimsy] branch master updated: Simplify using shared nominee matcher
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 c5fef89 Simplify using shared nominee matcher c5fef89 is described below commit c5fef89548f655fb4693b92b7150a5d10efc372d Author: Sebb AuthorDate: Sat Feb 27 23:35:20 2021 + Simplify using shared nominee matcher --- www/members/board-nominations.cgi | 33 + www/members/nominations.cgi | 32 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/www/members/board-nominations.cgi b/www/members/board-nominations.cgi index 0c2e982..f9b7529 100755 --- a/www/members/board-nominations.cgi +++ b/www/members/board-nominations.cgi @@ -46,12 +46,27 @@ def setup_data end # preload names - people = ASF::Person.preload('cn', + ASF::Person.preload('cn', nominations.map {|nominee| ASF::Person.find(nominee[:id])}) - return nominations, people, emails + return nominations, emails end +# create the match RE from a nominee +def create_match(nominee) + names = [] + pname = nominee[:name] + names << pname + names << pname.sub(%r{ [A-Z]\. }, ' ') # drop initial + personname = ASF::Person.find(nominee[:id]).public_name + names << personname if personname + list = names.uniq.map{|name| Regexp.escape(name)}.join('|') + # N.B. \b does not match if it follows ')', so won't match John (Fred) + # TODO: Work-round is to also look for EOS, but this needs to be improved + %r{\b(#{list})(\b|$)}i +end + + # produce HTML output of reports, highlighting ones that have not (yet) # been posted _html do @@ -78,7 +93,7 @@ _html do } ) do cur_mtg_dir = File.basename(MeetingUtil.get_latest(MEETINGS)) - nominations, people, emails = setup_data + nominations, emails = setup_data _div.flexbox do _div.flexitem do _h1_! do @@ -91,9 +106,8 @@ _html do _ul nominations.sort_by {|nominee| nominee[:name]} do |nominee| _li! do person = ASF::Person.find(nominee[:id]) - # N.B. \b does not match if it follows ')', so won't match John (Fred) - # TODO: Work-round is to also look for EOS, but this needs to be improved - match = /\b(#{Regexp.escape(nominee[:name]||'')}|#{Regexp.escape(person.public_name||'')})(\b|$)/i + + match = create_match(nominee) if emails.any? {|mail| mail.subject.downcase =~ match} _a.present person.public_name, href: "#{ROSTER}/#{nominee[:id]}" @@ -110,9 +124,6 @@ _html do end end -nominees = nominations.map! {|person| person[:name]} -nominees += people.map {|person| person.public_name} - _div.flexitem do _h1_.posted! do _a "Posted", href: @@ -134,9 +145,7 @@ _html do href = MBOX + mail.date.strftime('%Y%m') + '.mbox/' + ERB::Util.url_encode('<' + mail.message_id + '>') - # N.B. \b does not match if it follows ')', so won't match John (Fred) - # TODO: Work-round is to also look for EOS, but this needs to be improved - if nominees.any? {|name| mail.subject =~ /\b#{Regexp.escape(name)}(\b|$)/i} + if nominations.any? {|nominee| mail.subject =~ create_match(nominee)} _a.present mail.subject, href: href else _a.missing mail.subject, href: href diff --git a/www/members/nominations.cgi b/www/members/nominations.cgi index 1ab8f69..796e1c2 100755 --- a/www/members/nominations.cgi +++ b/www/members/nominations.cgi @@ -46,10 +46,24 @@ def setup_data end # preload names - people = ASF::Person.preload('cn', + ASF::Person.preload('cn', nominations.map {|nominee| ASF::Person.find(nominee[:id])}) - return nominations, people, emails + return nominations, emails +end + +# create the match RE from a nominee +def create_match(nominee) + names = [] + pname = nominee[:name] + names << pname + names << pname.sub(%r{ [A-Z]\. }, ' ') # drop initial + personname = ASF::Person.find(nominee[:id]).public_name + names << personname if personname + list = names.uniq.map{|name| Regexp.escape(name)}.join('|') + # N.B. \b does not match if it follows ')', so won't match John (Fred) + # TODO: Work-round is to also look for EOS, but this needs to be improved + %r{\b(#{list})(\b|$)}i end # produce HTML output of reports, highlighting ones that have not (yet) @@ -80,7 +94,7 @@ _html do } ) do cur_mtg_dir = File.basename(MeetingUtil.get_latest(MEETINGS)) - nominations, people, emails = setup_data + nominations, emails = setup_data _div.flexbox do _div.flexitem do _h1_! do @@ -94,9 +108,8 @@ _html do _ul nominations.sort_by
[whimsy] branch master updated: Simplify
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 d17db54 Simplify d17db54 is described below commit d17db5454ee904834c0c44bb9887af8d3f747466 Author: Sebb AuthorDate: Sat Feb 27 17:06:54 2021 + Simplify --- lib/whimsy/asf/member-files.rb | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/whimsy/asf/member-files.rb b/lib/whimsy/asf/member-files.rb index e30943b..f679674 100644 --- a/lib/whimsy/asf/member-files.rb +++ b/lib/whimsy/asf/member-files.rb @@ -38,7 +38,7 @@ module ASF block .slice_before(/^ +(\S+ \S+):\s*/) # split on the header names .each_with_index do |para, idx| - if idx == 0 # id and name + if idx == 0 # id and name (or just name for board) header = para.first.strip else key, value = para.shift.strip.split(': ',2) @@ -51,15 +51,7 @@ module ASF end end end -if header - yield header, nominee -else - unless block.join('') =~ /^\s*$/ # all blank or empty, e.g. trailing divider -Wunderbar.warn "Error, could not find public name" -Wunderbar.warn block.inspect -nominees['notinavail'] = {'Public Name' => '-- WARNING: unable to parse section --'} - end -end +yield header, nominee if header end end @@ -91,7 +83,7 @@ module ASF end if __FILE__ == $0 - ASF::MemberFiles.member_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name'].encoding]} + ASF::MemberFiles.member_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name']&.encoding]} puts "--" - ASF::MemberFiles.board_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name'].encoding]} + # ASF::MemberFiles.board_nominees.each {|k,v| p [k, v['Public Name'], v['Public Name']&.encoding]} end \ No newline at end of file
[whimsy] branch master updated: Simplify list matching
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 24fb123 Simplify list matching 24fb123 is described below commit 24fb12356861b8d3bb57e143d9979120f6ad0b70 Author: Sebb AuthorDate: Mon Feb 15 11:51:12 2021 + Simplify list matching Old-style podling lists have all been shut down --- lib/whimsy/asf/mlist.rb | 38 ++ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/whimsy/asf/mlist.rb b/lib/whimsy/asf/mlist.rb index beb65be..00f835b 100644 --- a/lib/whimsy/asf/mlist.rb +++ b/lib/whimsy/asf/mlist.rb @@ -121,6 +121,19 @@ module ASF response end +# helper function for matching against mod and subs entries +# does the target mail_domain match the current list? +def self.matches_list?(mail_domain, dom, list) +# normal tlp style (now also podlings): +#/home/apmail/lists/commons.apache.org/dev/mod +#Apache lists (e.g. some non-PMCs) +#/home/apmail/lists/apache.org/list/mod +return "#{mail_domain}.apache.org" == dom || + (dom == 'apache.org' && +(list == mail_domain || list.start_with?("#{mail_domain}-")) + ) +end + # for a mail domain, extract related lists and their moderators # also returns the time when the data was last checked # If podling==true, then also check for old-style podling names @@ -136,16 +149,9 @@ module ASF next if list =~ /^infra-[a-z]$/ next if dom == 'incubator.apache.org' && list =~ /^infra-dev2?$/ -# normal tlp style: -#/home/apmail/lists/commons.apache.org/dev/mod -# possible podling styles (new, old): -#/home/apmail/lists/batchee.apache.org/dev/mod -#/home/apmail/lists/incubator.apache.org/blur-dev/mod -#Apache lists (e.g. some non-PMCs) -#/home/apmail/lists/apache.org/list/mod -next unless "#{mail_domain}.apache.org" == dom or - (dom == 'apache.org' && list =~ /^#{mail_domain}(-|$)/) or - (podling && dom == 'incubator.apache.org' && list =~ /^#{mail_domain}-/) +# does the list match our target? +next unless matches_list?(mail_domain, dom, list) + moderators["#{list}@#{dom}"] = subs.sort end return moderators.to_h, (File.mtime(LIST_TIME) rescue File.mtime(LIST_MODS)) @@ -179,16 +185,8 @@ module ASF # normal tlp style: #/home/apmail/lists/commons.apache.org/dev/mod -# possible podling styles (new, old): -#/home/apmail/lists/batchee.apache.org/dev/mod -#/home/apmail/lists/incubator.apache.org/blur-dev/mod - -#Apache lists (e.g. some non-PMCs) -#/home/apmail/lists/apache.org/list/mod - -next unless "#{mail_domain}.apache.org" == dom or - (dom == 'apache.org' && list =~ /^#{mail_domain}(-|$)/) or - (podling && dom == 'incubator.apache.org' && list =~ /^#{mail_domain}-/) +# does the list match our target? +next unless matches_list?(mail_domain, dom, list) if skip_archivers subscribers["#{list}@#{dom}"] = list_subs ? subs.reject {|sub| is_archiver?(sub)}.sort : subs.reject {|sub| is_archiver?(sub)}.size
[whimsy] branch master updated: Simplify auth checks
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 cc61b5f Simplify auth checks cc61b5f is described below commit cc61b5f1f9cbfbc0768ee5f60f168bcc5b70e9dc Author: Sebb AuthorDate: Tue Dec 29 23:51:59 2020 + Simplify auth checks --- www/roster/models/committer.rb | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb index 3f75264..b6f7e07 100644 --- a/www/roster/models/committer.rb +++ b/www/roster/models/committer.rb @@ -24,10 +24,13 @@ class Committer name = {} +auth = Auth.info(env) +isSelfOrMember = (id == env.user or auth[:member]) + if person.icla name[:public_name] = person.public_name - if id == env.user or ASF::Person.find(env.user).asf_member? + if isSelfOrMember name[:legal_name] = person.icla.legal_name end end @@ -126,9 +129,9 @@ class Committer response[:forms] = {} -if ASF::Person.find(env.user).asf_member? # i.e. member karma +if auth[:member] # i.e. member karma - if person.icla and person.icla.claRef # Not all people have iclas + if person.icla and person.icla.claRef # Not all people have iclas (only check if secretary role) file = ASF::ICLAFiles.match_claRef(person.icla.claRef) if file url =ASF::SVN.svnurl('iclas') @@ -184,14 +187,13 @@ class Committer response[:member] = member unless member.empty? -if ASF::Person.find(env.user).asf_member? or env.user == id +if isSelfOrMember response[:moderates] = {} require 'whimsy/asf/mlist' ASF::MLIST.moderates(person.all_mail, response) end -auth = Auth.info(env) if env.user == id or auth[:root] or auth[:secretary] require 'whimsy/asf/mlist' ASF::MLIST.subscriptions(person.all_mail, response) # updates response[:subscriptions]
[whimsy] branch master updated: Simplify
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 92d022f Simplify 92d022f is described below commit 92d022fcdfc9111260683826456d741c185b4a84 Author: Sebb AuthorDate: Mon Nov 23 12:32:53 2020 + Simplify --- lib/whimsy/asf/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb index 00e4e15..517e721 100644 --- a/lib/whimsy/asf/git.rb +++ b/lib/whimsy/asf/git.rb @@ -62,7 +62,7 @@ module ASF @repos = Hash[Dir[*git].map { |name| if Dir.exist? name out, _, status = -Open3.capture3(*%(git config --get remote.origin.url), {chdir: name}) +Open3.capture3('git', 'config', '--get', 'remote.origin.url', {chdir: name}) if status.success? [File.basename(out.chomp, '.git'), name] end
[whimsy] branch master updated: Simplify
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 47b6ce9 Simplify 47b6ce9 is described below commit 47b6ce9d2f209306a547015dd80cfc9ef7d7295b Author: Sebb AuthorDate: Wed Oct 21 17:20:55 2020 +0100 Simplify if not => unless fix spacing --- lib/whimsy/asf/board.rb | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/whimsy/asf/board.rb b/lib/whimsy/asf/board.rb index b5edef1..5d1f1be 100644 --- a/lib/whimsy/asf/board.rb +++ b/lib/whimsy/asf/board.rb @@ -35,10 +35,10 @@ module ASF if withId ASF::Service['board'].members. map {|person| [person.id, {name: person.public_name}]}. - sort_by {|id,hash| hash[:name].split(' ').rotate(-1)}.to_h + sort_by {|_id, hash| hash[:name].split(' ').rotate(-1)}.to_h else ASF::Service['board'].members. - map {|person| person.public_name}. + map(&:public_name). sort_by {|name| name.split(' ').rotate(-1)} end end @@ -55,9 +55,9 @@ module ASF # time of next meeting def self.nextMeeting - time = self.calendar.select {|time| time > Time.now.utc}.min + time = self.calendar.select {|t| t > Time.now.utc}.min - if not time + unless time require 'chronic' this_month = Time.now.strftime('%B') @@ -76,9 +76,9 @@ module ASF # time of previous meeting def self.lastMeeting next_meeting = self.nextMeeting - time = self.calendar.select {|time| time < next_meeting}.max + time = self.calendar.select {|t| t < next_meeting}.max - if not time + unless time require 'chronic' this_month = Time.now.strftime('%B') @@ -124,7 +124,7 @@ module ASF def for(pmc) chair = pmc.chair -raise "no chair found for #{pmc.name}" if not chair +raise "no chair found for #{pmc.name}" unless chair if @directors.include? chair chair.public_name
[whimsy] branch master updated: Simplify by using Dir base: instead of chdir
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 1a06779 Simplify by using Dir base: instead of chdir 1a06779 is described below commit 1a0677988dc82299e1a0c47a915d88cdbd7a6b92 Author: Sebb AuthorDate: Mon Oct 19 23:35:34 2020 +0100 Simplify by using Dir base: instead of chdir --- www/board/agenda/routes.rb | 10 -- www/board/agenda/views/actions/draft.json.rb | 4 +--- www/board/agenda/views/actions/publish.json.rb | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb index 319fd32..f44297e 100755 --- a/www/board/agenda/routes.rb +++ b/www/board/agenda/routes.rb @@ -512,12 +512,10 @@ get '/text/draft/:file' do |file| agenda.sub('_agenda_', '_minutes_').sub('.txt', '.yml') _text do -Dir.chdir(FOUNDATION_BOARD) do - if Dir['board_agenda_*.txt'].include?(agenda) -_ Minutes.draft(agenda, minutes) - else -halt 404 - end +if Dir['board_agenda_*.txt', base: FOUNDATION_BOARD].include?(agenda) + _ Minutes.draft(agenda, minutes) +else + halt 404 end end end diff --git a/www/board/agenda/views/actions/draft.json.rb b/www/board/agenda/views/actions/draft.json.rb index 7b855ba..95558dc 100644 --- a/www/board/agenda/views/actions/draft.json.rb +++ b/www/board/agenda/views/actions/draft.json.rb @@ -22,6 +22,4 @@ ASF::SVN.update minutes_file, @message, env, _ do |tmpdir, old_contents| end end -drafts = Dir.chdir(FOUNDATION_BOARD) {Dir['board_minutes_*.txt'].sort} - -drafts +Dir['board_minutes_*.txt', base: FOUNDATION_BOARD].sort diff --git a/www/board/agenda/views/actions/publish.json.rb b/www/board/agenda/views/actions/publish.json.rb index 3e42f42..73d8f6e 100755 --- a/www/board/agenda/views/actions/publish.json.rb +++ b/www/board/agenda/views/actions/publish.json.rb @@ -126,4 +126,4 @@ ASF::SVN.update BOARD_PRIVATE, @message, env, _ do |tmpdir| end end -Dir.chdir(BOARD_PRIVATE) {Dir['board_minutes_*.txt'].sort} +Dir['board_minutes_*.txt', base: BOARD_PRIVATE].sort
[whimsy] branch master updated: Simplify by using new YamlFile method
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 2ae8285 Simplify by using new YamlFile method 2ae8285 is described below commit 2ae8285abb595f41fd4e85cbfc9c5f84319814cc Author: Sebb AuthorDate: Sat Oct 17 13:19:43 2020 +0100 Simplify by using new YamlFile method --- lib/whimsy/asf/committee.rb | 41 ++--- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb index b5415cc..7334a00 100644 --- a/lib/whimsy/asf/committee.rb +++ b/lib/whimsy/asf/committee.rb @@ -1,4 +1,5 @@ require 'time' +require 'whimsy/asf/yaml' module ASF @@ -632,38 +633,24 @@ module ASF meta[:description] if meta end - # append the description for a new tlp committee. # this is intended to be called from todos.json.rb in the block for ASF::SVN.update -def self.appendtlpmetadata(input,committee,description) - output = input # default no change - yaml = YAML.load input - if yaml[:cttees][committee] -Wunderbar.warn "Entry for '#{committee}' already exists under :cttees" - elsif yaml[:tlps][committee] -Wunderbar.warn "Entry for '#{committee}' already exists under :tlps" - else -data = { # create single entry in :tlps hierarchy - tlps: { -committee => { - site: "http://#{committee}.apache.org;, - description: description, -} +def self.appendtlpmetadata(input, committee, description) + YamlFile.replace_section(input, :tlps) do |section, yaml| +output = section # default no change +if yaml[:cttees][committee] + Wunderbar.warn "Entry for '#{committee}' already exists under :cttees" +elsif yaml[:tlps][committee] + Wunderbar.warn "Entry for '#{committee}' already exists under :tlps" +else + section[committee] = { +site: "http://#{committee}.apache.org;, +description: description, } -} -# Use YAML dump to ensure correct syntax -# drop the YAML header -newtlp = YAML.dump(data).sub(%r{^---\n:tlps:\n}m,'') -# add the new section just before the ... terminator -output = input.sub(%r{^\.\.\.},newtlp+"...") -# Check it worked -check = YAML.load(output) -unless data[:tlps][committee] == check[:tlps][committee] - Wunderbar.warn "Failed to add section for #{committee}" - output = input # don't change anything + output = section.sort.to_h end +output end - output end end
[whimsy] branch master updated: Simplify
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 a5bf8eb Simplify a5bf8eb is described below commit a5bf8ebf7b8abbe632911d3b19029f20e5d93a07 Author: Sebb AuthorDate: Sun Oct 11 14:52:57 2020 +0100 Simplify --- tools/collate_minutes.rb | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tools/collate_minutes.rb b/tools/collate_minutes.rb index f7d2cc2..52d6eaa 100755 --- a/tools/collate_minutes.rb +++ b/tools/collate_minutes.rb @@ -33,22 +33,8 @@ SITE_MINUTES = ASF::Config.get(:board_minutes) || File.expand_path('../../www/board/minutes', __FILE__) # list of SVN resources needed -resources = { - SVN_SITE_RECORDS_MINUTES: -'asf/infrastructure/site/trunk/content/foundation/records/minutes', - BOARD: 'private/foundation/board' -} - -# verify that the SVN resources can be found -resources.each do |const, location| - Kernel.const_set const, ASF::SVN[location] - unless Kernel.const_get const -STDERR.puts 'Unable to locate local checkout for ' + location -exit 1 - end -end - -incubator = URI.parse('http://incubator.apache.org/') +SVN_SITE_RECORDS_MINUTES = ASF::SVN['minutes'] +BOARD = ASF::SVN['foundation_board'] KEEP = ARGV.delete '--keep' # keep obsolete files? @@ -116,7 +102,7 @@ ASF::Podling.list.each do |podling| site[podling.name] = { name: podling.display_name, status: podling.status, -link: incubator + "projects/#{podling.name}.html", +link: "http://incubator.apache.org/projects/#{podling.name}.html;, text: podling.description } end
[whimsy] branch master updated: Simplify
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 e59204b Simplify e59204b is described below commit e59204b05c7134aa65eefab5faec92c808dc4c6b Author: Sebb AuthorDate: Thu Sep 24 17:51:20 2020 +0100 Simplify --- www/board/agenda/daemon/wsc.rb | 4 +++- www/board/agenda/daemon/wss.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/www/board/agenda/daemon/wsc.rb b/www/board/agenda/daemon/wsc.rb index 51bf41f..5cda25a 100644 --- a/www/board/agenda/daemon/wsc.rb +++ b/www/board/agenda/daemon/wsc.rb @@ -1,5 +1,7 @@ #!/usr/bin/env ruby -$:.unshift File.realpath(File.expand_path('../' * 5 + 'lib', __FILE__)) + +$LOAD_PATH.unshift '/srv/whimsy/lib' + require 'websocket-client-simple' require 'optparse' require 'ostruct' diff --git a/www/board/agenda/daemon/wss.rb b/www/board/agenda/daemon/wss.rb index 7647a3c..5b9d3d9 100755 --- a/www/board/agenda/daemon/wss.rb +++ b/www/board/agenda/daemon/wss.rb @@ -1,5 +1,7 @@ #!/usr/bin/env ruby -$:.unshift File.realpath(File.expand_path('../' * 5 + 'lib', __FILE__)) + +$LOAD_PATH.unshift '/srv/whimsy/lib' + require 'websocket-eventmachine-server' require 'listen' require 'ostruct'
[whimsy] branch master updated: Simplify: keys.each => each_key
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 49624af Simplify: keys.each => each_key 49624af is described below commit 49624af4d07031e792b283f12e3f6eaf948d024c Author: Sebb AuthorDate: Tue Sep 22 19:27:36 2020 +0100 Simplify: keys.each => each_key --- lib/whimsy/logparser.rb | 2 +- lib/whimsy/sitewebsite.rb| 6 +++--- tools/pubsub2rake.rb | 2 +- tools/site-scan.rb | 2 +- www/apmail/mods.cgi | 2 +- www/board/agenda/daemon/channel.rb | 2 +- www/board/agenda/views/actions/todos.json.rb | 2 +- www/events/talks.cgi | 2 +- www/members/board-attend.cgi | 2 +- www/test/secretary/workbench/email.rb| 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/whimsy/logparser.rb b/lib/whimsy/logparser.rb index 3c9cc62..515adee 100755 --- a/lib/whimsy/logparser.rb +++ b/lib/whimsy/logparser.rb @@ -95,7 +95,7 @@ module LogParser def collate_whimsy_access(logs, apphash = WHIMSY_APPS) remainder = logs apps = {} -apphash.keys.each do |a| +apphash.each_key do |a| apps[a] = Hash.new{|h,k| h[k] = [] } apps[a][RUSER] = Hash.new{|h,k| h[k] = 0 } apps[a][REFERER] = Hash.new{|h,k| h[k] = 0 } diff --git a/lib/whimsy/sitewebsite.rb b/lib/whimsy/sitewebsite.rb index 110b0b1..b8e4a5f 100644 --- a/lib/whimsy/sitewebsite.rb +++ b/lib/whimsy/sitewebsite.rb @@ -38,7 +38,7 @@ def display_project(project, links, analysis, checks, tlp = true) end end _tbody do -checks.keys.each do |col| +checks.each_key do |col| cls = SiteStandards.label(analysis, links, col, project) _tr do _td do @@ -163,7 +163,7 @@ def display_overview(sites, analysis, checks, tlp = true) _thead do _tr do _th! "#{tlp ? 'Project' : 'Podling'}", data_sort: 'string-ins' - checks.keys.each do |col| + checks.each_key do |col| _th! data_sort: 'string' do _a col.capitalize, href: "check/#{col}" _br @@ -186,7 +186,7 @@ def display_overview(sites, analysis, checks, tlp = true) _td do _a "#{links['display_name']}", href: "project/#{n}" end -checks.keys.each do |c| +checks.each_key do |c| cls = SiteStandards.label(analysis, links, c, n) _td '', class: cls, data_sort_value: sort_order[cls] end diff --git a/tools/pubsub2rake.rb b/tools/pubsub2rake.rb index d914922..e167f71 100755 --- a/tools/pubsub2rake.rb +++ b/tools/pubsub2rake.rb @@ -125,7 +125,7 @@ if $0 == __FILE__ watching = WATCH[path] watching.each do |svn_prefix, svn_alias, files| changed = event['commit']['changed'] -changed.keys.each do |ck| +changed.each_key do |ck| if ck.start_with? svn_prefix # file matches target path if files && files.size > 0 # but does it match exactly? files.each do |file| diff --git a/tools/site-scan.rb b/tools/site-scan.rb index 4d5e84d..3d02123 100755 --- a/tools/site-scan.rb +++ b/tools/site-scan.rb @@ -43,7 +43,7 @@ end # @see SiteStandards for definitions of what we should scan for (in general) def parse(id, site, name) data = {} - SiteStandards::COMMON_CHECKS.keys.each do |k| + SiteStandards::COMMON_CHECKS.each_key do |k| data[k.to_sym] = nil end data[:display_name] = name diff --git a/www/apmail/mods.cgi b/www/apmail/mods.cgi index 3dadb60..7b1e88e 100755 --- a/www/apmail/mods.cgi +++ b/www/apmail/mods.cgi @@ -100,7 +100,7 @@ _html do _h2_ "Mailing Lists - #{$1}" _ul do -mods[$1].keys.each do |list| +mods[$1].each_key do |list| _li! { _a list, href: "#{list}/" } end end diff --git a/www/board/agenda/daemon/channel.rb b/www/board/agenda/daemon/channel.rb index 6dbd294..52712d2 100644 --- a/www/board/agenda/daemon/channel.rb +++ b/www/board/agenda/daemon/channel.rb @@ -87,7 +87,7 @@ class Channel # close all open sockets def self.close_all -@@sockets.keys.each do |client| +@@sockets.each_key do |client| client.close end end diff --git a/www/board/agenda/views/actions/todos.json.rb b/www/board/agenda/views/actions/todos.json.rb index b948c70..98e236d 100644 --- a/www/board/agenda/views/actions/todos.json.rb +++ b/www/board/agenda/views/actions/todos.json.rb @@ -235,7 +235,7 @@ parsed_agenda.each do |item| next unless item[:attach] =~ /^7\w$/ if item['title'] =~ /^Change (.*?) Chair$/ and item['people'] pmc = ASF::Committee.find($1).id -item['people'].keys.each do |person| +
[whimsy] branch master updated: Simplify
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 b4d7264 Simplify b4d7264 is described below commit b4d7264a9ade24309b8c989e0a739b7cf929d49d Author: Sebb AuthorDate: Tue Sep 22 18:49:22 2020 +0100 Simplify --- lib/whimsy/asf/documents.rb | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb index b82f5ea..cb46c34 100644 --- a/lib/whimsy/asf/documents.rb +++ b/lib/whimsy/asf/documents.rb @@ -143,11 +143,9 @@ module ASF # or # nil, nil if not found def self.findpath(person) - path = file = nil - file = self.find(person) - if file -path = self.svnpath!(file) - end + path = nil + file = find(person) + path = svnpath!(file) if file [path, file] end @@ -157,17 +155,20 @@ module ASF # return the file name or nil if the file is not in the directory def self.extractfilenamefrom(rooturl, fileurl) return nil unless fileurl + # does the root match the file url? index = fileurl.index(rooturl) - if (index == 0) -# root matches, return file name (end of fileurl) -fileurl[rooturl.length..-1] - end + return nil unless index.zero? + + # root matches, return file name (end of fileurl) + fileurl[rooturl.length..-1] end + # Extract the file name if it is in emeritus directory # nil if it is not in this directory def self.extractfilename(fileurl) return nil unless fileurl + root_url = ASF::SVN.svnurl(@base) + '/' extractfilenamefrom(root_url, fileurl) end
[whimsy] branch master updated: Simplify using block
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 ba592c2 Simplify using block ba592c2 is described below commit ba592c2a6baef65fce3274c754c950f7c0b1517a Author: Sebb AuthorDate: Tue Sep 22 17:07:56 2020 +0100 Simplify using block --- lib/whimsy/asf/svn.rb | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 621d01f..dbc6c35 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -604,10 +604,10 @@ module ASF dir.untaint basename.untaint end - - tmpdir = Dir.mktmpdir.untaint - begin + rc = 0 + Dir.mktmpdir do |tmpdir| + # create an empty checkout self.svn_('checkout', [self.getInfoItem(dir,'url'), tmpdir], _, {depth: 'empty', env: env}) @@ -635,7 +635,7 @@ module ASF contents = yield tmpdir, '' previous_contents = File.read(tmpfile) if File.file? tmpfile end - + # create/update the temporary copy if contents and not contents.empty? File.write tmpfile, contents @@ -664,8 +664,7 @@ module ASF unless rc == 0 && out && out.empty? raise "svn failure #{rc} #{path.inspect} #{out}" end - ensure -FileUtils.rm_rf tmpdir + end rc # return last status end
[whimsy] branch master updated: Simplify: use existing method
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 3379935 Simplify: use existing method 3379935 is described below commit 3379935ef5664433bb4cb392ab140af7beb6f91c Author: Sebb AuthorDate: Sun Sep 20 17:31:02 2020 +0100 Simplify: use existing method --- lib/whimsy/asf/ldap.rb | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb index 236aa8c..e6dc4d9 100644 --- a/lib/whimsy/asf/ldap.rb +++ b/lib/whimsy/asf/ldap.rb @@ -571,12 +571,8 @@ module ASF # 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) + # add person to committers lists + register(person) # return new person person
[whimsy] branch master updated: Simplify
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 dff09fd Simplify dff09fd is described below commit dff09fd86729379a8a5da7b13c915322ba488fbf Author: Sebb AuthorDate: Fri Jul 24 22:31:04 2020 +0100 Simplify --- www/secretary/workbench/models/message.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb index b2ccc30..c4d3555 100644 --- a/www/secretary/workbench/models/message.rb +++ b/www/secretary/workbench/models/message.rb @@ -188,8 +188,7 @@ class Message # create directory, if necessary dest = File.join(repos, filename).untaint unless File.exist? dest -Dir.mkdir dest -Kernel.system 'svn', 'add', dest +Kernel.system 'svn', 'mkdir', dest end # write out selected attachment
[whimsy] branch master updated: Simplify: write atts to provided path
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 afd6e26 Simplify: write atts to provided path afd6e26 is described below commit afd6e26232ece21efae3b8cee85ba98e8f7766b2 Author: Sebb AuthorDate: Thu Jul 23 23:03:31 2020 +0100 Simplify: write atts to provided path --- www/secretary/workbench/models/message.rb | 25 ++--- www/secretary/workbench/tasks.rb | 17 - 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb index eccf9d6..b2ccc30 100644 --- a/www/secretary/workbench/models/message.rb +++ b/www/secretary/workbench/models/message.rb @@ -203,27 +203,22 @@ class Message # # write one or more attachments - # returns list of input names with their temporary file pointers - # It's not safe to return the path names of the temp files as - # that allows the files to be deleted by garbage collection - # [[name, open temp file, content-type]] - def write_att(*attachments) + # returns list as follows: + # [[name, temp file name, content-type]] + def write_att(tmpdir, *attachments) files = [] # drop all nil and empty values attachments = attachments.flatten.reject {|name| name.to_s.empty?} -if attachments.flatten.length == 1 - attachment = attachments.first - att = find(attachment) - files << [attachment, att.as_file, att.content_type.untaint] -else - # write out selected attachment - attachments.each do |attachment, basename| -att = find(attachment) -files << [attachment, att.as_file, att.content_type.untaint] - end +# write out any remaining attachments +attachments.each do |name| + att = find(name) + path = File.join(tmpdir, name) + att.write_path(path) + files << [name, path, att.content_type.untaint] end + files end diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb index a53bfdb..90ab4ef 100644 --- a/www/secretary/workbench/tasks.rb +++ b/www/secretary/workbench/tasks.rb @@ -80,7 +80,7 @@ class Wunderbar::JsonBuilder # Commit new file(s) and update associated index # e.g. add ccla.pdf, ccla.pdf.asc to documents/cclas/xyz/ and update officers/cclas.txt # Parameters: - # index_dir - SVN alias of directory containint the index (e.g. foundation or officers) + # index_dir - SVN alias of directory containing the index (e.g. foundation or officers) # index_name - name of index file to update (e.g. cclas.txt) # docdir - SVN alias for document directory (e.g. cclas) # docname - document name (as per email) @@ -91,11 +91,15 @@ class Wunderbar::JsonBuilder # svnmessage - the svn commit message # block - the block which is passed the contents of the index file to be updated def svn_multi(index_dir, index_name, docdir, docname, docsig, outfilename, outfileext, emessage, svnmessage, ) -ASF::SVN.multiUpdate_(ASF::SVN.svnpath!(index_dir, index_name), svnmessage, env, _) do |text| +rc = nil +Dir.mktmpdir do |tmpdir| + + rc = ASF::SVN.multiUpdate_(ASF::SVN.svnpath!(index_dir, index_name), svnmessage, env, _,{tmpdir: tmpdir}) do |text| extras = [] # write the attachments as file(s) - dest = emessage.write_att(docname, docsig) + dest = emessage.write_att(tmpdir, docname, docsig) + Wunderbar.warn dest.inspect if dest.size > 1 # write to a container directory unless outfilename =~ /\A[a-zA-Z][-.\w]+\z/ # previously done by write_svn @@ -115,7 +119,7 @@ class Wunderbar::JsonBuilder end outpath = File.join(container, name) # N.B. file cannot exist here, because the directory was created as part of the same commit - extras << ['put', file.path, outpath] + extras << ['put', file, outpath] extras << ['propset', 'svn:mime-type', content_type, outpath] end else @@ -125,7 +129,7 @@ class Wunderbar::JsonBuilder if ASF::SVN.exist?(outpath, nil, env) raise IOError.new("#{outpath} already exists!") else - extras << ['put', file.path, outpath] + extras << ['put', file, outpath] extras << ['propset', 'svn:mime-type', content_type, outpath] end end @@ -134,6 +138,9 @@ class Wunderbar::JsonBuilder [text, extras] end + + end + rc end def template(name)
[whimsy] branch master updated: Simplify by using library routine
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 89a78cd Simplify by using library routine 89a78cd is described below commit 89a78cd7f45e4dbb823c78ed98030eb9cf23a1dc Author: Sebb AuthorDate: Thu Jul 23 14:43:25 2020 +0100 Simplify by using library routine --- .../workbench/views/actions/memapp.json.rb | 41 +- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/www/secretary/workbench/views/actions/memapp.json.rb b/www/secretary/workbench/views/actions/memapp.json.rb index d9e7a18..4cf5a4e 100644 --- a/www/secretary/workbench/views/actions/memapp.json.rb +++ b/www/secretary/workbench/views/actions/memapp.json.rb @@ -135,20 +135,8 @@ task "subscribe to memb...@apache.org" do fn = "#{@availid}-members-#{Time.now.strftime '%Y%m%d-%H%M%S-%L'}.json" fn.untaint if @availid =~ /^\w[-.\w]+$/ -# checkout empty directory -svn 'checkout', '--depth', 'empty', - ASF::SVN.svnpath!('subreq'), - "#{dir}/subreq" - -# write out subscription request -File.write "#{dir}/subreq/#{fn}", @subreq -svn 'add', "#{dir}/subreq/#{fn}" - -# Show changes -svn 'diff', "#{dir}/subreq" - -# commit changes -svn 'commit', "#{dir}/subreq", '-m', @document +rc = ASF::SVN.create_(ASF::SVN.svnurl!('subreq'), fn, @subreq, @document, env, _) +raise RuntimeError.new("exit code: #{rc}") if rc != 0 end end @@ -175,26 +163,13 @@ task "svn commit memapp-received.text" do end complete do |dir| -# checkout empty directory meeting = file.split('/')[-2] -svn 'checkout', '--depth', 'empty', - ASF::SVN.svnpath!('Meetings', meeting), - File.join(dir, meeting) - -# retrieve memapp-received.txt -dest = "#{dir}/#{meeting}/memapp-received.txt" -svn 'update', dest - -# create/add file(s) -received = File.read(dest) -received[/.*\s#{@availid}\s.*/] = @line -File.write(dest, received) - -# Show changes -svn 'diff', "#{dir}/#{meeting}" - -# commit changes -svn 'commit', "#{dir}/#{meeting}/memapp-received.txt", '-m', @document +path = ASF::SVN.svnpath!('Meetings', meeting,'memapp-received.txt') +rc = ASF::SVN.update(path, @document, env, _, {diff: true}) do |tmpdir, input| + input[/.*\s#{@availid}\s.*/] = @line + input +end +raise RuntimeError.new("exit code: #{rc}") if rc != 0 end end
[whimsy] branch master updated: Simplify by using library methods
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 821d141 Simplify by using library methods 821d141 is described below commit 821d141a09156e4c30aca47e8648e00062076b72 Author: Sebb AuthorDate: Tue Jul 21 00:47:01 2020 +0100 Simplify by using library methods --- www/officers/acreq.cgi | 52 -- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/www/officers/acreq.cgi b/www/officers/acreq.cgi index 23a9b19..3c252de 100755 --- a/www/officers/acreq.cgi +++ b/www/officers/acreq.cgi @@ -8,9 +8,6 @@ require 'whimsy/asf/rack' require 'whimsy/asf' require 'mail' require 'date' -require 'open3' -require 'tmpdir' -require 'shellwords' user = ASF::Auth.decode(env = {}) unless user.asf_member? or ASF.pmc_chairs.include? user @@ -19,15 +16,12 @@ unless user.asf_member? or ASF.pmc_chairs.include? user exit end -ACREQ = 'https://svn.apache.org/repos/infra/infrastructure/trunk/acreq' -OFFICERS = 'https://svn.apache.org/repos/private/foundation/officers' +ICLAS = ASF::SVN.svnpath!('officers', 'iclas.txt') # get up to date data... -# TODO replace with library method see WHIMSY-103 -SVN = ("svn --username #{Shellwords.escape env.user} " + - "--password #{Shellwords.escape env.password}").untaint -requests = `#{SVN} cat #{ACREQ}/new-account-reqs.txt` -iclas_txt = `#{SVN} cat #{OFFICERS}/iclas.txt`.force_encoding('utf-8') +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 @@ -54,11 +48,10 @@ elsif iclas == '1' and email and iclas_txt =~ /^notinavail:.*?:(.*?):#{email}:/ iclas = {email => $1} else count = iclas ? iclas.to_i : 300 rescue 300 - oldrev = \ -`#{SVN} log --incremental -q -r HEAD:0 -l#{count} -- #{OFFICERS}/iclas.txt`. -split("\n")[-1].split()[0][1..-1].to_i - iclas = Hash[*`#{SVN} diff -r #{oldrev}:HEAD -- #{OFFICERS}/iclas.txt`. -scan(/^[+]notinavail:.*?:(.*?):(.*?):Signed CLA/).flatten.reverse] + 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] end # grab the list of userids that have been assigned (for validation purposes) @@ -339,29 +332,16 @@ _html do Using #{ENV['HTTP_USER_AGENT']} EOF - Dir.mktmpdir do |tmpdir| -tmpdir.untaint - -# Checkout the ACREQ directory -`#{SVN} co #{ACREQ} #{tmpdir}` - -# Update the new-account-reqs file... -File.open(File.join(tmpdir, 'new-account-reqs.txt'), 'a') do |file| - file.puts(line) -end - -# and commit the change ... + msg = "#{@user} account request by #{user.id} for #{requestor}" + rc = ASF::SVN.update(ASF::SVN.svnpath!('acreq', 'new-account-reqs.txt'), msg, env, _) do |dir, input| _h2 'Commit messages' -rc = ASF::SVN.svn_('commit', File.join(tmpdir, 'new-account-reqs.txt'), _, - {msg: "#{@user} account request by #{user.id} for #{requestor}", env: env}) - -if rc == 0 - mail.deliver! -else - tobe = 'that would have been ' -end +input + line + "\n" + end + if rc == 0 +mail.deliver! + else +tobe = 'that would have been ' end - # report on status _h2 "New entry #{tobe}added:" _pre line
[whimsy] branch master updated: Simplify; allow for missing epoch
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 8e58bb5 Simplify; allow for missing epoch 8e58bb5 is described below commit 8e58bb58b705abbf2ae03b92823642f88980c0bf Author: Sebb AuthorDate: Thu Jul 16 16:13:05 2020 +0100 Simplify; allow for missing epoch --- www/roster/models/committer.rb | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb index 0afb1fd..db4ab32 100644 --- a/www/roster/models/committer.rb +++ b/www/roster/models/committer.rb @@ -151,24 +151,26 @@ class Committer file = ASF::EmeritusFiles.find(person) if file - response[:forms][:emeritus] = ASF::SVN.svnpath!('emeritus', file) + response[:forms][:emeritus] = ASF::EmeritusFiles.svnpath!(file) end epoch, file = ASF::EmeritusRequestFiles.find(person, true) if file - response[:forms][:emeritus_request] = ASF::SVN.svnpath!('emeritus-requests-received', file) + response[:forms][:emeritus_request] = ASF::EmeritusRequestFiles.svnpath!(file) # Calculate the age in days response[:emeritus_request_age] = (((Time.now.to_i - epoch.to_i).to_f/SECS_TO_DAYS)).round(1).to_s +elsif epoch # listing does not have both epoch and file + response[:forms][:emeritus_request] = ASF::EmeritusRequestFiles.svnpath!(epoch) end file = ASF::EmeritusRescindedFiles.find(person) if file - response[:forms][:emeritus_rescinded] = ASF::SVN.svnpath!('emeritus-requests-rescinded', file) + response[:forms][:emeritus_rescinded] = ASF::EmeritusRescindedFiles.svnpath!(file) end file = ASF::EmeritusReinstatedFiles.find(person) if file - response[:forms][:emeritus_reinstated] = ASF::SVN.svnpath!('emeritus-reinstated', file) + response[:forms][:emeritus_reinstated] = ASF::EmeritusReinstatedFiles.svnpath!(file) end else
[whimsy] branch master updated: Simplify
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 92d2362 Simplify 92d2362 is described below commit 92d2362f43d7a11fcf5db96620247ab5a05a09b0 Author: Sebb AuthorDate: Thu Jul 16 16:08:05 2020 +0100 Simplify --- lib/whimsy/asf/documents.rb | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb index 532bdf7..5836b6b 100644 --- a/lib/whimsy/asf/documents.rb +++ b/lib/whimsy/asf/documents.rb @@ -118,12 +118,10 @@ module ASF downcase.gsub(' ','-').gsub(/[^a-z0-9-]+/,'') rescue nil id = person.id files = self.listnames(getDate).find_all do |file| -if getDate - # allow for missing epoch - stem = [file].pop.split('.')[0] # directories don't have a trailing / -else - stem = file.split('.')[0] # directories don't have a trailing / +if file.is_a?(Array) # we have [epoch, file] + file = file[1] end +stem = file.split('.')[0] # directories don't have a trailing / stem == id or stem == name end # Only valid if we match a single file or directory
[whimsy] branch master updated: Simplify; fail on error
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 2189dba Simplify; fail on error 2189dba is described below commit 2189dba8fd0af9309b5eda03e99f188f572552b2 Author: Sebb AuthorDate: Thu Jul 9 23:18:29 2020 +0100 Simplify; fail on error --- www/roster/views/actions/memstat.json.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/roster/views/actions/memstat.json.rb b/www/roster/views/actions/memstat.json.rb index bedf130..f28c8df 100644 --- a/www/roster/views/actions/memstat.json.rb +++ b/www/roster/views/actions/memstat.json.rb @@ -56,8 +56,8 @@ end # Owner operations if @action == 'rescind_emeritus' - emeritus_rescinded_url = ASF::SVN.svnurl('emeritus-requests-rescinded') - ASF::SVN.svn_('mv', [@emeritusfileurl, emeritus_rescinded_url], _, {env:env, msg:message}) + # TODO handle case where rescinded file already exists + ASF::SVN.svn_!('mv', [@emeritusfileurl, ASF::SVN.svnurl('emeritus-requests-rescinded')], _, {env:env, msg:message}) elsif @action == 'request_emeritus' # Create mail to secretary requesting emeritus template, err =
[whimsy] branch master updated: Simplify by using library method
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 2bef2fb Simplify by using library method 2bef2fb is described below commit 2bef2fbd725fae3629029003923dd193e2e5fcde Author: Sebb AuthorDate: Thu Jul 9 22:49:22 2020 +0100 Simplify by using library method --- www/roster/models/committer.rb | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb index 7944802..9148165 100644 --- a/www/roster/models/committer.rb +++ b/www/roster/models/committer.rb @@ -149,26 +149,22 @@ class Committer file = ASF::EmeritusFiles.find(person) if file - url = ASF::SVN.svnurl('emeritus') - response[:forms][:emeritus] = "#{url}/#{file}" + response[:forms][:emeritus] = ASF::SVN.svnpath!('emeritus', file) end file = ASF::EmeritusRequestFiles.find(person) if file - url = ASF::SVN.svnurl('emeritus-requests-received') - response[:forms][:emeritus_request] = "#{url}/#{file}" + response[:forms][:emeritus_request] = ASF::SVN.svnpath!('emeritus-requests-received', file) end file = ASF::EmeritusRescindedFiles.find(person) if file - url = ASF::SVN.svnurl('emeritus-requests-rescinded') - response[:forms][:emeritus_rescinded] = "#{url}/#{file}" + response[:forms][:emeritus_rescinded] = ASF::SVN.svnpath!('emeritus-requests-rescinded', file) end file = ASF::EmeritusReinstatedFiles.find(person) if file - url = ASF::SVN.svnurl('emeritus-reinstated') - response[:forms][:emeritus_reinstated] = "#{url}/#{file}" + response[:forms][:emeritus_reinstated] = ASF::SVN.svnpath!('emeritus-reinstated', file) end else
[whimsy] branch master updated: Simplify by using SVN.update method
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 3b39c32 Simplify by using SVN.update method 3b39c32 is described below commit 3b39c328ec8285a040c2d62399f0039b1fdcf08b Author: Sebb AuthorDate: Wed Jul 8 21:02:46 2020 +0100 Simplify by using SVN.update method --- www/secretary/workbench/views/actions/ccla.json.rb | 21 - 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/www/secretary/workbench/views/actions/ccla.json.rb b/www/secretary/workbench/views/actions/ccla.json.rb index fa8f7a0..54f88b3 100644 --- a/www/secretary/workbench/views/actions/ccla.json.rb +++ b/www/secretary/workbench/views/actions/ccla.json.rb @@ -90,23 +90,10 @@ task "svn commit foundation/officers/cclas.txt" do end complete do |dir| -# checkout empty officers directory -svn 'checkout', '--depth', 'empty', - ASF::SVN.svnurl!('officers'), - File.join(dir, 'officers') - -# retrieve cclas.txt -dest = File.join(dir, 'officers', 'cclas.txt') -svn 'update', dest - -# update cclas.txt -File.write dest, File.read(dest) + @cclalines + "\n" - -# show the changes -svn 'diff', dest - -# commit changes -svn 'commit', dest, '-m', @document +path = ASF::SVN.svnpath!('officers', 'cclas.txt') +ASF::SVN.update(path, @document, env, _, {diff: true}) do |tmpdir, contents| + contents + @cclalines + "\n" +end end end
[whimsy] branch master updated: simplify
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 08f34ae simplify 08f34ae is described below commit 08f34ae13647a0ec077d5bf6fb35daef7de5a6b1 Author: Sam Ruby AuthorDate: Sun Jul 5 17:01:04 2020 -0400 simplify --- tools/pubsub.rb | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/pubsub.rb b/tools/pubsub.rb index 6d4924f..eb144e9 100644 --- a/tools/pubsub.rb +++ b/tools/pubsub.rb @@ -232,14 +232,7 @@ end if restartable STDERR.puts 'restarting' - # reconstruct path to Ruby executable - require 'rbconfig' - ruby = File.join( -RbConfig::CONFIG["bindir"], -RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] - ) - # relaunch script after a one second delay sleep 1 - exec ruby, __FILE__, *ARGV + exec RbConfig.ruby, __FILE__, *ARGV end
[whimsy] branch master updated: Simplify debug
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 2b7ebb9 Simplify debug 2b7ebb9 is described below commit 2b7ebb9587e95e4f896dfbc0ea255b12e8b4cc57 Author: Sebb AuthorDate: Wed Jul 1 00:28:25 2020 +0100 Simplify debug --- lib/spec/lib/svn_wunderbar_spec.rb | 2 +- lib/whimsy/asf/svn.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/spec/lib/svn_wunderbar_spec.rb b/lib/spec/lib/svn_wunderbar_spec.rb index 20cb24f..ef6faed 100644 --- a/lib/spec/lib/svn_wunderbar_spec.rb +++ b/lib/spec/lib/svn_wunderbar_spec.rb @@ -68,7 +68,7 @@ describe "ASF::SVN.svn_" do expect(rc).to be(0) expect(out['transcript'].class).to equal(Array) exp = ["svn", "info", "--non-interactive", "--", "https://svn.apache.org/repos/asf/attic/site/xdocs/projects/_template.xml;] -expect(out['transcript'][1]).to eq(exp.inspect) +expect(out['transcript'][1]).to eq(exp.join(' ')) end it "svn_('info', 'no file') should fail with E29" do repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'___') diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 9c49f0d..d13ddaa 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -445,8 +445,7 @@ module ASF _.system ['echo', [cmd,sysopts].inspect] if options[:verbose] # includes auth if options[:dryrun] # excludes auth -# TODO: improve this -return _.system ['echo', cmd.inspect] +return _.system cmd.insert(0,'echo') end # N.B. Version 1.3.3 requires separate hashes for JsonBuilder and BuilderClass,
[whimsy] branch master updated: Simplify by using msg: and depth:
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 dc3f187 Simplify by using msg: and depth: dc3f187 is described below commit dc3f187aa12942ad123fa7ad16a0d179f4eeb452 Author: Sebb AuthorDate: Fri Jun 12 14:14:22 2020 +0100 Simplify by using msg: and depth: --- www/committers/subscribe.cgi | 2 +- www/members/inactive.cgi | 4 ++-- www/members/mentor-update.cgi | 2 +- www/members/proxy.cgi | 2 +- www/officers/acreq.cgi| 2 +- www/officers/surveys.cgi | 4 ++-- www/treasurer/bill-upload.cgi | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/www/committers/subscribe.cgi b/www/committers/subscribe.cgi index eb85e31..1994b98 100755 --- a/www/committers/subscribe.cgi +++ b/www/committers/subscribe.cgi @@ -272,7 +272,7 @@ _html do message = "#{@list} -= #{$USER}" end -options = credentials.merge({args: ['--message', message]}) +options = credentials.merge({msg: message}) rc = ASF::SVN.svn_('commit', fn, _, options) end end diff --git a/www/members/inactive.cgi b/www/members/inactive.cgi index 624832c..b9a0977 100755 --- a/www/members/inactive.cgi +++ b/www/members/inactive.cgi @@ -114,7 +114,7 @@ _html do Dir.mktmpdir do |dir| _div_.transcript do work = ASF::SVN.getInfoItem(latest,'url') - ASF::SVN.svn_('checkout', [work, dir], _, {args: ['--depth', 'empty']}.merge(auth)) + ASF::SVN.svn_('checkout', [work, dir], _, {depth: 'empty'}.merge(auth)) json = File.join(dir, 'non-participants.json') ASF::SVN.svn_('update', json, _, auth) tracker = JSON.parse(IO.read(json)) @@ -122,7 +122,7 @@ _html do tracker[$USER]['status'] = @suggestions IO.write(json, JSON.pretty_generate(tracker)) ASF::SVN.svn_('diff', json, _, {verbose: true, sysopts: {hilite: [/"status":/]}}) - ASF::SVN.svn_('commit', json, _, {args: ['--message', @status]}.merge(auth)) + ASF::SVN.svn_('commit', json, _, {msg: @status}.merge(auth)) end end end diff --git a/www/members/mentor-update.cgi b/www/members/mentor-update.cgi index 8ee86cf..df43358 100755 --- a/www/members/mentor-update.cgi +++ b/www/members/mentor-update.cgi @@ -138,7 +138,7 @@ def send_form(formdata: {}) ASF::SVN.svn_('add', fn, _) message = "#{$USER} += mentoring volunteer (whimsy)" end - rc = ASF::SVN.svn_('commit', fn, _, {args: ['--message', message]}.merge(credentials)] + rc = ASF::SVN.svn_('commit', fn, _, {msg: message}.merge(credentials)] end end diff --git a/www/members/proxy.cgi b/www/members/proxy.cgi index 3037acd..288bf69 100755 --- a/www/members/proxy.cgi +++ b/www/members/proxy.cgi @@ -229,7 +229,7 @@ def emit_post(cur_mtg_dir, meeting) # commit ASF::SVN.svn_('commit',[filename, 'proxies'], _, - {args: ['--message', "assign #{@proxy} as my proxy"], user: $USER, password: $PASSWORD}) + {msg: "assign #{@proxy} as my proxy", user: $USER, password: $PASSWORD}) # TODO: send email to @proxy per WHIMSY-78 end end diff --git a/www/officers/acreq.cgi b/www/officers/acreq.cgi index 92d70a2..23a9b19 100755 --- a/www/officers/acreq.cgi +++ b/www/officers/acreq.cgi @@ -353,7 +353,7 @@ _html do # and commit the change ... _h2 'Commit messages' rc = ASF::SVN.svn_('commit', File.join(tmpdir, 'new-account-reqs.txt'), _, - {args: ['--message', "#{@user} account request by #{user.id} for #{requestor}"], env: env}) + {msg: "#{@user} account request by #{user.id} for #{requestor}", env: env}) if rc == 0 mail.deliver! diff --git a/www/officers/surveys.cgi b/www/officers/surveys.cgi index 4b338b1..44225a2 100755 --- a/www/officers/surveys.cgi +++ b/www/officers/surveys.cgi @@ -118,7 +118,7 @@ def submit_survey(formdata: {}) rc = 999 # Ensure it's a bogus value Dir.mktmpdir do |tmpdir| tmpdir.untaint -ASF::SVN.svn_('checkout',[get_survey_root(), tmpdir],_,{args: ['--depth', 'files'], user: $USER, password: $PASSWORD}) +ASF::SVN.svn_('checkout',[get_survey_root(), tmpdir],_,{depth: 'files', user: $USER, password: $PASSWORD}) survey_data = JSON.parse(File.read(filename), :symbolize_names => true) # Add user data (may overwrite existing entry!) @@ -128,7 +128,7 @@ def submit_survey(formdata: {}) File.write(filename, JSON.pretty_generate(survey_data)) Dir.chdir tmpdir do - # rc = ASF::SVN.svn_('commit', filename, _, {args:
[whimsy] branch master updated: Simplify by using existing methods
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 7503c04 Simplify by using existing methods 7503c04 is described below commit 7503c04461be19a2c19d52014728d98d763a562d Author: Sebb AuthorDate: Sat Jun 6 15:58:00 2020 +0100 Simplify by using existing methods --- lib/whimsy/asf/svn.rb | 30 +++--- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 9af5dbb..c9a73e1 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -341,31 +341,15 @@ module ASF end # retrieve revision, content for a file in svn +# N.B. There is a window between fetching the revision and getting the file contents def self.get(path, user=nil, password=nil) - # build svn info command - cmd = ['svn', 'info', path, '--non-interactive'] - - # password was supplied, add credentials - if password -cmd += ['--username', user, '--password', password, '--no-auth-cache'] - end - - # default the values to return - revision = '0' - content = nil - - # issue svn info command - stdout, status = Open3.capture2(*cmd) - if status.success? -# extract revision number -revision = stdout[/^Revision: (\d+)/, 1] - -# extract contents -cmd[1] = 'cat' -content, status = Open3.capture2(*cmd) + revision, _ = self.getInfoItem(path, 'revision', {user: user, password: password}) + if revision +content, _ = self.svn('cat', path, {user: user, password: password}) + else +revision = '0' +content = nil end - - # return results return revision, content end
[whimsy] branch master updated: Simplify
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 9ca6c16 Simplify 9ca6c16 is described below commit 9ca6c16d485da0338f6286fa35835d890da0b93b Author: Sebb AuthorDate: Fri Jun 5 18:08:31 2020 +0100 Simplify --- lib/whimsy/asf/committee.rb | 3 +-- lib/whimsy/asf/icla.rb| 3 +-- lib/whimsy/asf/svn.rb | 2 +- www/board/agenda/models/agenda.rb | 2 +- www/members/inactive.cgi | 2 +- www/members/proxy.cgi | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb index a50f27a..00c2853 100644 --- a/lib/whimsy/asf/committee.rb +++ b/lib/whimsy/asf/committee.rb @@ -117,8 +117,7 @@ module ASF end @committee_mtime = File.mtime(file) -@@svn_change = Time.parse( - `svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime +@@svn_change = Time.parse(ASF::SVN.getInfoItem(file,'last-changed-date')).gmtime parse_committee_info File.read(file) end diff --git a/lib/whimsy/asf/icla.rb b/lib/whimsy/asf/icla.rb index 56698ec..7142c2c 100644 --- a/lib/whimsy/asf/icla.rb +++ b/lib/whimsy/asf/icla.rb @@ -55,8 +55,7 @@ module ASF def self.svn_change self.refresh if SOURCE -@@svn_change ||= Time.parse( - `svn info #{SOURCE}`[/Last Changed Date: (.*) \(/, 1]).gmtime +@@svn_change ||= Time.parse(ASF::SVN.getInfoItem(SOURCE,'last-changed-date')).gmtime end end diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index d88d36e..6f1d722 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -443,7 +443,7 @@ module ASF # create an empty checkout _.system ['svn', 'checkout', '--depth', 'empty', '--non-interactive', ['--username', env.user, '--password', env.password], - `svn info #{dir}`[/URL: (.*)/, 1], tmpdir] + self.getInfoItem(dir,'url'), tmpdir] # retrieve the file to be updated (may not exist) if basename diff --git a/www/board/agenda/models/agenda.rb b/www/board/agenda/models/agenda.rb index b3ddce8..cdb3d4b 100755 --- a/www/board/agenda/models/agenda.rb +++ b/www/board/agenda/models/agenda.rb @@ -157,7 +157,7 @@ class Agenda baseline = File.read(path) if Agenda[file][:mtime] == File.mtime(path) # check out empty directory - board = `svn info #{FOUNDATION_BOARD}`[/URL: (.*)/, 1] + board = ASF::SVN.getInfoItem(FOUNDATION_BOARD,'url') _.system ['svn', 'checkout', auth, '--depth', 'empty', board, dir] # update the file in question diff --git a/www/members/inactive.cgi b/www/members/inactive.cgi index cc000a9..9dd7f1e 100755 --- a/www/members/inactive.cgi +++ b/www/members/inactive.cgi @@ -113,7 +113,7 @@ _html do # apply and commit changes Dir.mktmpdir do |dir| _div_.transcript do - work = `svn info #{latest}`[/URL: (.*)/, 1] + work = ASF::SVN.getInfoItem(latest,'url') _.system ['svn', 'checkout', auth, '--depth', 'empty', work, dir] json = File.join(dir, 'non-participants.json') _.system ['svn', 'update', auth, json] diff --git a/www/members/proxy.cgi b/www/members/proxy.cgi index 3eec727..c397255 100755 --- a/www/members/proxy.cgi +++ b/www/members/proxy.cgi @@ -179,7 +179,7 @@ def emit_post(cur_mtg_dir, meeting) # report on commit _div.transcript do Dir.mktmpdir do |tmpdir| - svn = `svn info #{MEETINGS}/#{meeting}`[/URL: (.*)/, 1] + svn = ASF::SVN.getInfoItem(File.join(MEETINGS,meeting),'url') _.system [ 'svn', 'checkout', '--quiet', svn.untaint, tmpdir.untaint,
[whimsy] branch master updated: Simplify
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 6dd6303 Simplify 6dd6303 is described below commit 6dd63039863cd9036571f0313700c61ec0f8bc25 Author: Sebb AuthorDate: Fri Jun 5 17:50:27 2020 +0100 Simplify --- lib/whimsy/asf/member.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/whimsy/asf/member.rb b/lib/whimsy/asf/member.rb index 12cb218..5a331b0 100644 --- a/lib/whimsy/asf/member.rb +++ b/lib/whimsy/asf/member.rb @@ -111,9 +111,8 @@ module ASF # Return the Last Changed Date for members.txt in svn as # a Time object. def self.svn_change - foundation = ASF::SVN['foundation'] - file = File.join(foundation, 'members.txt') - return Time.parse(`svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime + file = File.join(ASF::SVN['foundation'], 'members.txt') + return Time.parse(ASF::SVN.getInfoItem(file,'last-changed-date')).gmtime end # sort an entire members.txt file
[whimsy] branch master updated: Simplify
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 128580c Simplify 128580c is described below commit 128580c27d6ab0c6e5fc1eff128c192931f9d187 Author: Sebb AuthorDate: Fri Jun 5 17:35:59 2020 +0100 Simplify --- www/board/agenda/routes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb index 6a4c7f5..233409a 100755 --- a/www/board/agenda/routes.rb +++ b/www/board/agenda/routes.rb @@ -521,9 +521,10 @@ get '/new' do @prev_month = @meeting.to_date.prev_month.strftime('%B') # retrieve latest committee info + # TODO: this is the workspace copy -- should it be using the copy from SVN instead? cinfo = File.join(ASF::SVN['board'], 'committee-info.txt') info = ASF::SVN.getInfo(cinfo, env.user, env.password) - _, contents = ASF::SVN.get(cinfo, env.user, env.password) + contents = ASF::SVN.svn('cat', cinfo, {env: env}) ASF::Committee.load_committee_info(contents, info) # extract committees expected to report 'next month'
[whimsy] branch master updated: Simplify updateCI by using common svn() method
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 1abc586 Simplify updateCI by using common svn() method 1abc586 is described below commit 1abc586b2f57fdea7de3d073f8047475df94be88 Author: Sebb AuthorDate: Fri Jun 5 00:52:34 2020 +0100 Simplify updateCI by using common svn() method --- lib/whimsy/asf/svn.rb | 31 +-- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 3adac2a..92db8a9 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -366,17 +366,18 @@ module ASF # user and password are required because the default URL is private def self.updateCI(msg, env, options={}) # Allow override for testing - ciURL = options[:url] || 'https://svn.apache.org/repos/private/committers/board' + ciURL = options[:url] || self.svnurl('board') Dir.mktmpdir do |tmpdir| # use dup to make testing easier user = env.user.dup.untaint pass = env.password.dup.untaint # checkout committers/board (this does not have many files currently) -Kernel.system 'svn', 'checkout', '--quiet', - '--no-auth-cache', '--non-interactive', - '--depth', 'files', - '--username', user , '--password', pass, - ciURL, tmpdir.untaint +out, err = self.svn('checkout', ciURL, + {flags: [tmpdir.untaint, '--quiet', '--depth', 'files'], + user: user, password: pass}) + +raise Exception.new("Checkout of board folder failed: #{err}") unless out + # read in committee-info.txt file = File.join(tmpdir, 'committee-info.txt') info = File.read(file) @@ -386,19 +387,13 @@ module ASF # write updated file to disk File.write(file, info) -# commit changes -rc = Kernel.system 'svn', 'commit', '--quiet', - '--no-auth-cache', '--non-interactive', - '--username', user, '--password', pass, - file, '--message', msg +# commit the updated file +out, err = self.svn('commit', file, + {flags: [tmpdir.untaint,'--quiet', '--message', msg], + user: user, password: pass}) -if rc - # update cache - ASF::Committee.parse_committee_info(info) -else - # die - raise Exception.new('Update committee-info.txt failed') -end +raise Exception.new("Update of committee-info.txt failed: #{err}") unless out + end end
[whimsy] branch master updated: Simplify front page and add officer's tool listing
This is an automated email from the ASF dual-hosted git repository. curcuru 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 59bbe3e Simplify front page and add officer's tool listing 59bbe3e is described below commit 59bbe3e137a8090a440a5097ce41832bd8215a5a Author: Shane Curcuru AuthorDate: Tue Apr 14 17:48:17 2020 -0400 Simplify front page and add officer's tool listing --- www/index.html | 32 +- www/officers/index.cgi | 61 ++ 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/www/index.html b/www/index.html index ba69ee8..9526076 100644 --- a/www/index.html +++ b/www/index.html @@ -84,7 +84,7 @@ Whimsy is a site where a set of unnecessary yet highly useful applications are deployed at Apache. - The http://whimsical.apache.org/;>Apache Whimsy PMC manages this server, and maintains the tools here. + The https://whimsical.apache.org/;>Apache Whimsy PMC manages this server, and maintains the tools here. Our focus is on providing organizational information about the ASF and our projects in easy to consume ways, and to help automate corporate processes at the ASF to make the paperwork behind the scenes easier for our many volunteers. @@ -121,7 +121,7 @@ https://people.apache.org/unlistedclas.html;>Persons with signed CLAs but who are not (yet) committers. https://www.apache.org/dev;>Apache Developer How-Tos https://community.apache.org/;>Apache Community How-Tos -https://reference.apache.org/;>Apache Infra Reference Library +https://infra.apache.org/;>Apache Infra Reference Library @@ -161,17 +161,13 @@ - Available to Members and Officers + Tools Restricted To Officers Or Members Board Agenda -New Account Request -ICLAs -Mailing List Request -Bill Upload -PMC-chair vs board subscriptions -Board mail traffic analysis +Overview Of Useful Officer Tools +Overview Of Useful Member Tools @@ -179,24 +175,6 @@ - - - Available to Members - - - -Member subscription cross-checks -Member watch -STV Explorer -Proxy form (ASF members meeting) -Security Mailing List Subscriptions -Archiver Subscription Issues - ignoring missing mail-archive subs -Archiver Subscription Issues - including missing mail-archive subs -Archiver Subscription Checks (all entries) - - - - Available to Secretarial Team diff --git a/www/officers/index.cgi b/www/officers/index.cgi new file mode 100755 index 000..bb052aa --- /dev/null +++ b/www/officers/index.cgi @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby +PAGETITLE = "Overview of Whimsy Tools for Officers" # Wvisible:meeting + +$LOAD_PATH.unshift '/srv/whimsy/lib' +require 'json' +require 'whimsy/asf' +require 'wunderbar' +require 'wunderbar/bootstrap' + +OFFICERS = { + '/board/agenda' => "Monthly Board Agenda Tool", + 'acreq.cgi' => "New Account Request Helper", + 'mlreq.cgi' => "New Mailing List Request Form", + '/committers/subscribe.cgi' => "Apache Mailing List Subscription/Unsubscription Tool", + '/board/subscriptions' => "PMC Chair board@ Subscription Crosscheck", + 'list-traffic.cgi' => "Statistics About The board@ Mailing List", + 'board-stats.cgi' => "Statistics About Board Meetings", + '/treasurer/bill-upload' => "Treasurer's Bill Upload Helper", + 'http://treasurer.apache.org' => "Treasurer's Office Payment Processing Overview", + 'https://www.apache.org/foundation/governance/orgchart' => "Apache Corporate Organization Chart" +} + +_html do + _body? do +_whimsy_body( + title: PAGETITLE, + subtitle: 'Officer and Member-restricted tools only', + relatedtitle: 'More Useful Links', + related: { +"/committers/tools" => "Whimsy All Available Tools Listing", +"https://svn.apache.org/repos/private/foundation/; => "Checkout the private 'foundation/officers' repo for Officers", + "https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}" => "See This Source Code", +"mailto:d...@whimsical.apache.org?subject=[FEEDBACK] members/index idea" => "Email Feedback
[whimsy] branch master updated: simplify
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 bc7e29f simplify bc7e29f is described below commit bc7e29f8026e378ee360ff7c0369adb4235b Author: Sebb AuthorDate: Sun Mar 8 17:43:47 2020 + simplify --- tools/deliver.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/deliver.rb b/tools/deliver.rb index d7f1543..1473a1f 100644 --- a/tools/deliver.rb +++ b/tools/deliver.rb @@ -27,11 +27,12 @@ hdrs = mail[/\A(.*?)\r?\n\r?\n/m, 1] || '' # extract info dest = hdrs[/^List-Id: <(.*)>/, 1] || hdrs[/^Delivered-To.* (\S+)\s*$/, 1] || 'unknown' +list = dest[/^[-\w]+/] month = Time.now.strftime('%Y%m') hash = Digest::SHA1.hexdigest(getmid(hdrs) || mail)[0..9] # build file name -file = "#{MAIL_ROOT}/#{dest[/^[-\w]+/]}/#{month}/#{hash}" +file = File.join(MAIL_ROOT,list, month, hash) File.umask 0002 FileUtils.mkdir_p File.dirname(file)
[whimsy] branch master updated: Simplify formatting
This is an automated email from the ASF dual-hosted git repository. curcuru 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 07af23e Simplify formatting 07af23e is described below commit 07af23ea2b62371a122ce895890314464ed6d2bb Author: Shane Curcuru AuthorDate: Tue Feb 4 10:56:57 2020 -0500 Simplify formatting --- www/members/list-traffic.cgi | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/members/list-traffic.cgi b/www/members/list-traffic.cgi index 32ea605..7e32d65 100755 --- a/www/members/list-traffic.cgi +++ b/www/members/list-traffic.cgi @@ -52,8 +52,10 @@ def display_monthly(months:, nondiscuss:) _div.col_sm_6 do _ul.list_group do _li.list_group_item.list_group_item_info "Long Tail - All Senders" - data[MailUtils::MAILCOUNT].each do |id, num| -_li.list_group_item "#{id} (#{num}), " + _li.list_group_item do +data[MailUtils::MAILCOUNT].each do |id, num| + _! "#{id} (#{num}), " +end end end end
[whimsy] branch master updated: Simplify; drop unused vars
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 8be2d6c Simplify; drop unused vars 8be2d6c is described below commit 8be2d6ce151502714b0917a33dc4994de1723512 Author: Sebb AuthorDate: Sun Jan 12 22:21:50 2020 + Simplify; drop unused vars --- lib/whimsy/asf/ldap.rb | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb index 49f0dbe..e2669aa 100644 --- a/lib/whimsy/asf/ldap.rb +++ b/lib/whimsy/asf/ldap.rb @@ -198,7 +198,7 @@ module ASF def self.extract_cert host = hosts.sample[%r{//(.*?)(/|$)}, 1] puts ['openssl', 's_client', '-connect', host, '-showcerts'].join(' ') - out, err, rc = Open3.capture3 'openssl', 's_client', + out, _, _ = Open3.capture3 'openssl', 's_client', '-connect', host, '-showcerts' out[/^-+BEGIN.*?\n-+END[^\n]+\n/m] end @@ -1023,16 +1023,12 @@ module ASF # return a list of ASF::People who are members of this group def members - members = weakref(:members) do -ASF.search_one(base, "cn=#{name}", 'memberUid').flatten - end - - members.map {|uid| Person.find(uid)} + memberids.map {|uid| Person.find(uid)} end # return a list of ids who are members of this group def memberids - members = weakref(:members) do + weakref(:members) do ASF.search_one(base, "cn=#{name}", 'memberUid').flatten end end
[whimsy] branch master updated: Simplify
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 176c753 Simplify 176c753 is described below commit 176c7533e142618fe20127fff163dc3199425cfd Author: Sebb AuthorDate: Thu Jan 9 10:23:22 2020 + Simplify --- DEPLOYMENT.md | 7 --- 1 file changed, 7 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 1a04c84..b0a4b5b 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -85,13 +85,6 @@ and running - these are only needed for a new deployment. * `/x1/srv/git/letsencrypt/letsencrypt-auto --apache -d whimsy.apache.org -d whimsy4.apache.org -d whimsy-vm4.apache.org -d whimsy-test.apache.org` * The SVN settings should now be set up in whimsy-vm5 and later (Puppet 6) - * Check that `/home/whimsysvn/.subversion/config` and - `/home/whimsysvn/.subversion/servers` are configured to store auth-creds. - There should be two files under `/home/whimsysvn/.subversion/auth/svn.simple` - - * Check that `/var/www/.subversion/config` and - `/var/www/.subversion/servers` are configured to use the `whimsysvn` user and to *not* - store the auth-creds. * Update the following cron scripts under https://svn.apache.org/repos/infra/infrastructure/apmail/trunk/bin: * listmodsubs.sh - add the new host
[whimsy] branch master updated: Simplify check
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 50b3009 Simplify check 50b3009 is described below commit 50b30092c3a6e21178b16aac9ed8209018711bf9 Author: Sebb AuthorDate: Thu Oct 24 14:11:00 2019 +0100 Simplify check No need to test for presence of SVN dir if override flag is specified --- lib/spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb index f48d0f7..4041bea 100644 --- a/lib/spec/spec_helper.rb +++ b/lib/spec/spec_helper.rb @@ -2,7 +2,7 @@ $LOAD_PATH.unshift '/srv/whimsy/lib' require 'whimsy/asf' # Override with test data if there is no checkout available (allows local use) -unless ASF::SVN.find('apmail_bin') and not ENV['RAKE_TEST'] == 'TRUE' +if ENV['RAKE_TEST'] == 'TRUE' or not ASF::SVN.find('apmail_bin') TEST_DATA = true # Test data is smaller so some tests need adjusting puts "Overriding data directories" ASF::SVN['apmail_bin'] = File.expand_path('../test/svn/apmail_bin', __dir__)
[whimsy] branch master updated: Simplify; $stderr should go to /srv/svn/procmail.log
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 7a98a7d Simplify; $stderr should go to /srv/svn/procmail.log 7a98a7d is described below commit 7a98a7d60055121587c3284179651c8939148c99 Author: Sebb AuthorDate: Thu Jul 18 14:01:26 2019 +0100 Simplify; $stderr should go to /srv/svn/procmail.log --- tools/svnupdate.rb | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/svnupdate.rb b/tools/svnupdate.rb index 6a4e379..7da7de1 100644 --- a/tools/svnupdate.rb +++ b/tools/svnupdate.rb @@ -13,27 +13,21 @@ mail = Mail.new(STDIN.read) # This must agree with the file used by the svnupdate cron job LOG = '/srv/whimsy/www/logs/svn-update' -# More testing -LOGTMP = '/srv/whimsy/www/logs/svn-update.tmp' -$stderr.reopen(File.new(LOGTMP,'at')) -$stdout.reopen(File.new(LOGTMP,'at')) - def update(dir) # prevent concurrent updates being performed by the cron job File.open(LOG, File::RDWR|File::CREAT, 0644) do |log| log.flock(File::LOCK_EX) -puts "#{Time.now} Updating #{dir}" # Temporary test +$stderr.puts "#{Time.now} Updating #{dir}" # Temporary test Dir.chdir dir do - puts `svn cleanup` - puts `svn update` + $stderr.puts `svn cleanup` + $stderr.puts `svn update` end end end if mail.subject =~ %r{^board: r\d+ -( in)? /foundation/board} # board-commits@ - puts "Matched board" # test # prevent concurrent updates being performed by the cron job File.open(LOG, File::RDWR|File::CREAT, 0644) do |log| log.flock(File::LOCK_EX) @@ -72,7 +66,5 @@ elsif mail.subject =~ %r{^bills: r\d+ -( in)? /financials/Bills} # operations@ end end -else - puts mail.subject # temporary test end
[whimsy] branch master updated: Simplify/shorten
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 2eca08f Simplify/shorten 2eca08f is described below commit 2eca08f70ec38a1fbb862c4132186169b937d1d3 Author: Sebb AuthorDate: Sun Apr 7 12:51:30 2019 +0100 Simplify/shorten --- www/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/index.html b/www/index.html index 1ef5151..1c4b8e0 100644 --- a/www/index.html +++ b/www/index.html @@ -182,9 +182,9 @@ STV Explorer Proxy form (ASF members meeting) Security Mailing List Subscriptions -CrossCheck of Archiver Subscriptions (issues only - excluding missing mail-archive subscriptions) -CrossCheck of Archiver Subscriptions (issues only - including missing mail-archive subscriptions) -CrossCheck of Archiver Subscriptions (all entries) +Archiver Subscription Issues - excluding missing mail-archive subs +Archiver Subscription Issues - including missing mail-archive subs +Archiver Subscription Checks (all entries)
[whimsy] branch master updated: Simplify
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 2dda82b Simplify 2dda82b is described below commit 2dda82ba91949df936108aa538e3f7924a826024 Author: Sebb AuthorDate: Fri Mar 8 08:49:22 2019 + Simplify --- www/roster/views/committees.html.rb | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/www/roster/views/committees.html.rb b/www/roster/views/committees.html.rb index d451e6f..92eb58a 100644 --- a/www/roster/views/committees.html.rb +++ b/www/roster/views/committees.html.rb @@ -39,14 +39,15 @@ _html do prev_letter=nil @committees.sort_by {|pmc| pmc.display_name.downcase}.each do |pmc| letter = pmc.display_name.upcase[0] -_tr_ do +if letter != prev_letter + options = {id: letter} +else + options = {} +end +prev_letter = letter +_tr_ options do _td do -if letter != prev_letter - _a pmc.display_name, href: "committee/#{pmc.name}", id: letter -else - _a pmc.display_name, href: "committee/#{pmc.name}" -end -prev_letter = letter +_a pmc.display_name, href: "committee/#{pmc.name}" end _td do
[whimsy] branch master updated: Simplify as source files are in SVN
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 763527f Simplify as source files are in SVN 763527f is described below commit 763527ff9b70d9cf1674094bb0d89440dcfd0b72 Author: Sebb AuthorDate: Mon Jan 7 11:59:51 2019 + Simplify as source files are in SVN --- tools/toccomments.sh | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tools/toccomments.sh b/tools/toccomments.sh index 80f1d2b..021f1cb 100755 --- a/tools/toccomments.sh +++ b/tools/toccomments.sh @@ -1,18 +1,9 @@ #!/usr/bin/env bash # Fix incorrectly wrapped comments in Incubator ToC section +# Intended for use on archived agendas and published minutes. # Look for Comments: preceeded by non-space -ruby -p -i.orig -e 'gsub(/(\S)\s+(Comments:)/,"\\1\n \\2")' "$@" -for i in "$@" -do - # if the files are the same, drop the unchanged output - if cmp -s $i $i.orig - then - echo "$i has not changed" - rm $i.orig - else - echo "$i has changed" -# ls -l $i* - fi -done +ruby -p -i -e 'gsub(/(\S)\s+(Comments:)/,"\\1\n \\2")' "$@" +# no need to save original files as tool is intended for use with files in SVN/Git +echo "Done; the updated files can be diffed/checked in as required" \ No newline at end of file
[whimsy] branch master updated: Simplify screen
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 57052dc Simplify screen 57052dc is described below commit 57052dcb83734d1a68b804f05c09c48f3a973b5a Author: Sebb AuthorDate: Thu Aug 16 12:30:56 2018 +0100 Simplify screen --- tools/moderationhelper.rb | 19 --- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/moderationhelper.rb b/tools/moderationhelper.rb index 11fb95a..2591428 100755 --- a/tools/moderationhelper.rb +++ b/tools/moderationhelper.rb @@ -47,6 +47,14 @@ _html do _ 'Press Generate. The To: address below can be copy/pasted into an email to send. In most cases you must be a moderator for that list.' end _p do + _ul do +_li 'subscribers can post and will receive mail' +_li 'allow-subscribers can post; they do not get copies of mails (this is used for e.g. press@)' +_li 'deny-subscribers cannot post; their posts will be rejected without needing moderation' +_li 'sendsubscribertomod-subscribers will have all posts moderated (for posters who are borderline problems) - ask INFRA to enable the setting for the list' + end +end +_p do _span.text_danger 'BETA SOFTWARE: double-check the command first. ' _a "Feedback welcome!", href: "mailto:d...@whimsical.apache.org?Subject=Feedback on moderation helper app" end @@ -54,17 +62,6 @@ _html do ) do _form method: 'post' do _fieldset do - _legend 'Mail Moderation Helper' - - _p do -_ul do - _li 'subscribers can post and will receive mail' - _li 'allow-subscribers can post; they do not get copies of mails (this is used for e.g. press@)' - _li 'deny-subscribers cannot post; their posts will be rejected without needing moderation' - _li 'sendsubscribertomod-subscribers will have all posts moderated (for posters who are borderline problems) - ask INFRA to enable the setting for the list' -end - end - _table do _tr do _th 'Mailing list'
[whimsy] branch master updated: Simplify by using instance variables
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 abf8406 Simplify by using instance variables abf8406 is described below commit abf840629a995caf0e02d9e15dacd783bfe672ad Author: Sebb AuthorDate: Fri Jul 6 11:35:25 2018 +0100 Simplify by using instance variables Also now agrees with other action modules --- www/project/icla/views/actions/update.json.rb | 107 -- 1 file changed, 48 insertions(+), 59 deletions(-) diff --git a/www/project/icla/views/actions/update.json.rb b/www/project/icla/views/actions/update.json.rb index 50c6d32..ff71da8 100644 --- a/www/project/icla/views/actions/update.json.rb +++ b/www/project/icla/views/actions/update.json.rb @@ -35,9 +35,8 @@ VALID_PHASES=%w{discuss vote cancelled tallied invite} VALID_VOTES=%w{+1 +0 -0 -1} # Tally the votes and send them -def sendTally(data, contents) - member = data['member'] # currently logged in - user_email = "#{member}@apache.org" +def sendTally(contents) + user_email = "#{@member}@apache.org" pmc = ASF::Committee.find(contents['project']) pmc_email = "#{pmc.mail_list}@apache.org" subject = "[RESULT]" + contents['subject'] @@ -77,79 +76,72 @@ def sendTally(data, contents) mail.deliver end -def update(data) +def update() # setup and validation - token = data['token'] - raise ArgumentError.new('token must not be nil') unless token - action = data['action'] - raise ArgumentError.new("Invalid action: '#{action}'") unless VALID_ACTIONS.include? action - member = data['member'] - comment = data['comment'] # may be nil - expectedPhase = data['expectedPhase'] - raise ArgumentError.new('expectedPhase must not be nil') unless expectedPhase - newPhase = data['newPhase'] # nil for no change - if newPhase and not VALID_PHASES.include? newPhase -raise ArgumentError.new("Invalid newPhase: '#{newPhase}'") + raise ArgumentError.new('token must not be nil') unless @token + raise ArgumentError.new("Invalid action: '#{@action}'") unless VALID_ACTIONS.include? @action + raise ArgumentError.new('expectedPhase must not be nil') unless @expectedPhase + if @newPhase and not VALID_PHASES.include? @newPhase +raise ArgumentError.new("Invalid @newPhase: '#{@newPhase}'") end timestamp = Time.now.utc.to_s addComment = nil voteinfo = nil - if action == 'submitVote' -vote = data['vote'] -raise ArgumentError.new("Invalid vote: '#{vote}'") unless VALID_VOTES.include? vote -raise ArgumentError.new('member must not be nil') unless member -if vote == '-1' - raise ArgumentError.new('-1 vote must have comment') unless comment + if @action == 'submitVote' +raise ArgumentError.new("Invalid vote: '#{@vote}'") unless VALID_VOTES.include? @vote +raise ArgumentError.new('member must not be nil') unless @member +if @vote == '-1' + raise ArgumentError.new('-1 vote must have comment') unless @comment end -if comment # allow comment for other votes +if @comment # allow comment for other votes voteinfo = { -'vote' => vote, -'comment' => comment, -'member' => member, +'vote' => @vote, +'comment' => @comment, +'member' => @member, 'timestamp' => timestamp, } else voteinfo = { -'vote' => vote, -'member' => member, +'vote' => @vote, +'member' => @member, 'timestamp' => timestamp, } end - elsif HAS_COMMENT.include? action -if comment + elsif HAS_COMMENT.include? @action +if @comment addComment = { -'comment' => comment, -'member' => member, +'comment' => @comment, +'member' => @member, 'timestamp' => timestamp, } else - raise ArgumentError.new("comment must not be nil for '#{action}'") + raise ArgumentError.new("comment must not be nil for '#{@action}'") end end - file = "/srv/icla/#{token}.json" + file = "/srv/icla/#{@token}.json" # now read/update the file if necessary contents = {} # define the var outside the block rewrite = false # should the file be updated? - phases = *expectedPhase # convert string to array + phases = *@expectedPhase # convert string to array LockFile.lockfile(file, 'r+', File::LOCK_EX) do |f| contents = JSON::parse(f.read) phase = contents['phase'] -raise ArgumentError.new("Phase '#{phase}': expected '#{expectedPhase}'") unless expectedPhase == '*' or phases.include? phase -if newPhase && newPhase != phase - contents['phase'] = newPhase +raise ArgumentError.new("Phase '#{phase}': expected '#{@expectedPhase}'") unless @expectedPhase == '*' or phases.include? phase +if @newPhase && @newPhase != phase + contents['phase'] = @newPhase
[whimsy] branch master updated: Simplify by passing expected and new phases from caller
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 c6e7284 Simplify by passing expected and new phases from caller c6e7284 is described below commit c6e72846f468775fd51edd57fd1331ba1293e9f7 Author: Sebb AuthorDate: Thu Jul 5 01:39:05 2018 +0100 Simplify by passing expected and new phases from caller Update code can be better controlled from caller --- www/project/icla/views/actions/update.json.rb | 113 -- www/project/icla/views/pages/discuss.js.rb| 9 +- www/project/icla/views/pages/vote.js.rb | 15 ++-- 3 files changed, 84 insertions(+), 53 deletions(-) diff --git a/www/project/icla/views/actions/update.json.rb b/www/project/icla/views/actions/update.json.rb index 3a476c6..3267b58 100644 --- a/www/project/icla/views/actions/update.json.rb +++ b/www/project/icla/views/actions/update.json.rb @@ -1,6 +1,7 @@ # # Common methods to update the progress file -# TODO also send emails? +# +# Called from JS pages using POST # $LOAD_PATH.unshift '/srv/whimsy/lib' @@ -8,24 +9,39 @@ $LOAD_PATH.unshift '/srv/whimsy/lib' require 'json' require 'whimsy/lockfile' -# TODO add emails where necessary # TODO add some kind of history to show who changed the phase and when # This probably needs to be held separately from comments +# Simplify validation +VALID_ACTIONS=%w{submitVote cancelVote tallyVote submitComment startVoting invite} +HAS_COMMENT=%w{submitComment startVoting invite} # do we update the comments array? +VALID_PHASES=%w{discuss vote cancelled tallied invite} +VALID_VOTES=%w{+1 +0 -0 -1} + def update(data) - token = data['token'] - file = "/srv/icla/#{token}.json" + # setup and validation + token = data['token'] + raise ArgumentError.new('token must not be nil') unless token action = data['action'] - timestamp = Time.now.to_s[0..9] + raise ArgumentError.new("Invalid action: '#{action}'") unless VALID_ACTIONS.include? action member = data['member'] comment = data['comment'] # may be nil + expectedPhase = data['expectedPhase'] + raise ArgumentError.new('expectedPhase must not be nil') unless expectedPhase + newPhase = data['newPhase'] # nil for no change + if newPhase and not VALID_PHASES.include? newPhase +raise ArgumentError.new("Invalid newPhase: '#{newPhase}'") + end + timestamp = Time.now.to_s[0..9] + addComment = nil + voteinfo = nil if action == 'submitVote' vote = data['vote'] -raise 'vote must not be nil' unless vote -raise 'member must not be nil' unless member +raise ArgumentError.new("Invalid vote: '#{vote}'") unless VALID_VOTES.include? vote +raise ArgumentError.new('member must not be nil') unless member if vote == '-1' - raise '-1 vote must have comment' unless comment + raise ArgumentError.new('-1 vote must have comment') unless comment end if comment # allow comment for other votes voteinfo = { @@ -41,42 +57,41 @@ def update(data) 'timestamp' => timestamp, } end + elsif HAS_COMMENT.include? action +if comment + addComment = + { +comment: comment, +member: member, +timestamp: timestamp, + } +else + raise ArgumentError.new("comment must not be nil for '#{action}'") +end end + + file = "/srv/icla/#{token}.json" + + # now read/update the file if necessary contents = {} # define the var outside the block + rewrite = false # should the file be updated? + phases = *expectedPhase # convert string to array + LockFile.lockfile(file, 'r+', File::LOCK_EX) do |f| contents = JSON::parse(f.read) -rewrite = false # should the file be updated? -case action - # These are the vote actions - when 'submitVote' -# keep the same phase -contents['votes'] << voteinfo -rewrite = true - when 'cancelVote' -contents['phase'] = 'cancelled' -rewrite = true - when 'tallyVote' -contents['phase'] = 'tallied' # is that necessary? Can we tally again? -rewrite = true # only needed if phase is updated - - # these are the discuss actions - when 'submitComment', 'startVoting', 'invite' # discuss -contents['comments'] << { - comment: comment, - member: member, - timestamp: timestamp, -} -# Might be better for the caller to provide the new phase -if action == 'startVoting' - contents['phase'] = 'vote' - contents['votes'] ||= [] # make sure there is a votes array -end -contents['phase'] = 'invite' if action == 'invite' -rewrite = true - - # unknown - else -raise "InvalidAction: #{action}" +phase = contents['phase'] +raise ArgumentError.new("Phase '#{phase}': expected
[whimsy] branch master updated: Simplify; let nil mean no error
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 5f994f3 Simplify; let nil mean no error 5f994f3 is described below commit 5f994f36b9d6810db48dfa00cf3103f416a70ac3 Author: Sebb AuthorDate: Wed Jul 4 08:47:03 2018 +0100 Simplify; let nil mean no error --- lib/whimsy/lockfile.rb | 19 +-- www/project/icla/views/actions/discuss.json.rb | 10 +++--- www/project/icla/views/actions/vote.json.rb| 12 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/whimsy/lockfile.rb b/lib/whimsy/lockfile.rb index 57d5515..02fafbf 100644 --- a/lib/whimsy/lockfile.rb +++ b/lib/whimsy/lockfile.rb @@ -6,8 +6,8 @@ module LockFile - # create a new file and return an error if it already exists - def self.create_ex(filename, verbose=false) + # create a new file and return an error if it already exists, otherwise nil + def self.create_ex(filename) err = nil begin File.open(filename, File::WRONLY|File::CREAT|File::EXCL) do |file| @@ -16,7 +16,7 @@ module LockFile rescue => e err = e end -return verbose ? [err==nil, err] : err==nil +err end # lock an open file and ensure it gets unlocked @@ -50,11 +50,10 @@ if __FILE__ == $0 name = ARGV.shift || '/tmp/lockfile1' text = "#{Time.now}\n" puts "#{Time.now} #{test} using #{name}" + ret = nil case test when 'create' ret = LockFile.create_ex(name) {|f| f << text} - when 'createShow' -ret = LockFile.create_ex(name, true) {|f| f << text} when 'opena' puts "#{Time.now} Wait lock" ret = LockFile.lockfile(name, 'a', File::LOCK_EX) do |f| @@ -84,6 +83,14 @@ if __FILE__ == $0 else raise "Unexpected test: #{test}" end + puts ret.class.inspect puts ret.inspect - puts File.read(name) + if ret +if Errno::EEXIST === ret + puts "Already exists!" +else + puts "Some other error" +end + end + puts File.read(name) unless ret end diff --git a/www/project/icla/views/actions/discuss.json.rb b/www/project/icla/views/actions/discuss.json.rb index c2da67a..1c1f783 100644 --- a/www/project/icla/views/actions/discuss.json.rb +++ b/www/project/icla/views/actions/discuss.json.rb @@ -47,11 +47,15 @@ token = pmc.name + '-' + date + '-' + Digest::MD5.hexdigest(@iclaemail)[0..5] file_name = '/srv/icla/' + token + '.json' # important not to overwrite any existing files -if LockFile.create_ex(file_name.untaint) do |f| +err = LockFile.create_ex(file_name.untaint) do |f| f.write(JSON.pretty_generate(discussion)) +end +if err + if Errno::EEXIST === err +_error 'There is already a file for that person!' + else +_error err.inspect end -else - _error 'There is already a file for that person!' end # add user and pmc emails to the response diff --git a/www/project/icla/views/actions/vote.json.rb b/www/project/icla/views/actions/vote.json.rb index b80d50d..e6b0306 100644 --- a/www/project/icla/views/actions/vote.json.rb +++ b/www/project/icla/views/actions/vote.json.rb @@ -26,7 +26,7 @@ rescue _focus :iclaemail end # create the vote object -date = Time.now.to_date.to_s +date = Time.now.to_date.to_s # requires 'time' (seems to be pulled in by 'mail') contributor = {:name => @iclaname, :email => @iclaemail} comment = @proposalText + "\n" + @voteComment votes = [{:vote =>'+1', :member => @proposer, :timestamp => date, :comment => comment}] @@ -46,11 +46,15 @@ token = pmc.name + '-' + date + '-' + Digest::MD5.hexdigest(@iclaemail)[0..5] file_name = '/srv/icla/' + token + '.json' # important not to overwrite any existing files -if LockFile.create_ex(file_name.untaint) do |f| +err = LockFile.create_ex(file_name.untaint) do |f| f.write(JSON.pretty_generate(discussion)) +end +if err + if Errno::EEXIST === err +_error 'There is already a file for that person!' + else +_error err.inspect end -else - _error 'There is already a file for that person!' end
[whimsy] branch master updated: Simplify id validation - copy code from committee
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 beab937 Simplify id validation - copy code from committee beab937 is described below commit beab9374c9267dca7e48eaefcc9b32eb9ec84eb8 Author: SebbAuthorDate: Fri Dec 15 13:37:15 2017 + Simplify id validation - copy code from committee --- www/roster/views/actions/ppmc.json.rb | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/www/roster/views/actions/ppmc.json.rb b/www/roster/views/actions/ppmc.json.rb index 0f29252..fb476e5 100644 --- a/www/roster/views/actions/ppmc.json.rb +++ b/www/roster/views/actions/ppmc.json.rb @@ -1,6 +1,12 @@ if env.password - # Allow for missing people - people = @ids.split(',').map {|id| ASF::Person[id] || ASF::Person.find(id) } + + # validate ids + if @action == 'remove' +people = @ids.split(',').map {|id| ASF::Person.find(id)} + else +people = @ids.split(',').map {|id| ASF::Person[id]} +raise ArgumentError.new("ids=#{@ids}") if people.any? {|person| person.nil?} + end # if target is ONLY icommit, use incubator in the email message, etc. # Otherwise, use the project (podling). @@ -10,11 +16,6 @@ if env.password project = ASF::Project[@project] end - # validate arguments (dn attribute is only present for real people) - if @action != 'remove' and people.any? {|person| person.attrs['dn'].nil?} -raise ArgumentError.new("ids=#{@ids}") - end - unless @action == 'add' and @targets.include? 'ldap' raise ArgumentError.new("project=#{@project}") unless project end -- To stop receiving notification emails like this one, please contact ['"commits@whimsical.apache.org" '].
[whimsy] branch master updated: simplify
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 2cdef7c simplify 2cdef7c is described below commit 2cdef7c5ad84c0c080f00b8ca2eb77eec814476e Author: Sam RubyAuthorDate: Fri Sep 29 22:13:39 2017 -0400 simplify --- www/board/agenda/views/models/minutes.js.rb | 19 +-- 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/www/board/agenda/views/models/minutes.js.rb b/www/board/agenda/views/models/minutes.js.rb index 35defb4..33e7a39 100644 --- a/www/board/agenda/views/models/minutes.js.rb +++ b/www/board/agenda/views/models/minutes.js.rb @@ -7,24 +7,7 @@ class Minutes # (re)-load minutes def self.load(list) -old_keys = @@list.keys() - -if list - for title in list -index = old_keys.indexOf(title) -if index >= 0 - @@list[title]=list[title] - old_keys.splice(index, 1) -else - Vue.set @@list, title, list[title] -end - end -end - -old_keys.each do |key| - Vue.delete @@list, key -end - +@@list = list Vue.set @@list, 'attendance', {} unless @@list.attendance end -- To stop receiving notification emails like this one, please contact ['"commits@whimsical.apache.org" '].
[whimsy] branch master updated: Simplify access to public JSON files
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 70c6b40 Simplify access to public JSON files 70c6b40 is described below commit 70c6b402dd7339002b6323319a5e8376d6238bc2 Author: SebbAuthorDate: Thu Jun 8 00:30:34 2017 +0100 Simplify access to public JSON files --- lib/whimsy/public.rb | 35 +++ 1 file changed, 35 insertions(+) diff --git a/lib/whimsy/public.rb b/lib/whimsy/public.rb new file mode 100644 index 000..843ef40 --- /dev/null +++ b/lib/whimsy/public.rb @@ -0,0 +1,35 @@ +# +# Simplify access to JSON files in the /public/ directory +# + +require 'json' +#require 'wunderbar' +require 'net/https' +require 'fileutils' + +module Public + DATAURI = 'https://whimsy.apache.org/public/' + + def self.getfile(pubname) +local_copy = File.expand_path('../../../www/public/'+pubname, __FILE__.untaint).untaint +if File.exist? local_copy +# Wunderbar.info "Using local copy of #{pubname}" + File.read(local_copy) +else +# Wunderbar.info "Fetching remote copy of #{pubname}" + response = Net::HTTP.get_response(URI(DATAURI+pubname)) + raise ArgumentError, "'#{pubname}' #{response.message}" unless response.is_a?(Net::HTTPSuccess) + response.body +end + end + + def self.getJSON(pubname) +JSON.parse(getfile(pubname)) + end +end + +# for test purposes +if __FILE__ == $0 + puts Public.getJSON('public_podling_status.json')['last_updated'] + puts Public.getJSON('public_ldap_services.json')['lastTimestamp'] +end -- To stop receiving notification emails like this one, please contact ['"commits@whimsical.apache.org" '].