You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/07/22 16:51:20 UTC
[whimsy] branch master updated: WHIMSY-336 icla commit should be
atomic
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 a1fbdc4 WHIMSY-336 icla commit should be atomic
a1fbdc4 is described below
commit a1fbdc4a275404b86ce2eeffa159997a88b95be9
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jul 22 17:51:11 2020 +0100
WHIMSY-336 icla commit should be atomic
Also fix broken rename of files to icla.ext[.asc]
---
www/secretary/workbench/tasks.rb | 9 +++
www/secretary/workbench/views/actions/icla.json.rb | 78 ++++++----------------
2 files changed, 31 insertions(+), 56 deletions(-)
diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb
index c9f3592..0d519d4 100644
--- a/www/secretary/workbench/tasks.rb
+++ b/www/secretary/workbench/tasks.rb
@@ -104,6 +104,15 @@ class Wunderbar::JsonBuilder
container = ASF::SVN.svnpath!(docdir, outfilename)
extras << ['mkdir', container]
dest.each do |name, file|
+ if docdir == 'iclas' && outfileext # special processing for output name
+ if name == docname
+ name = "icla%s" % outfileext
+ elsif name == docsig
+ name = "icla%s.asc" % outfileext
+ else
+ Wunderbar.warn "Cannot recognise #{name} as #{docname} or #{docsig}"
+ end
+ end
# N.B. file cannot exist here, because the directory was created as part of the same commit
extras << ['put', file.path, File.join(container, name)]
end
diff --git a/www/secretary/workbench/views/actions/icla.json.rb b/www/secretary/workbench/views/actions/icla.json.rb
index 69d69e9..4072eec 100644
--- a/www/secretary/workbench/views/actions/icla.json.rb
+++ b/www/secretary/workbench/views/actions/icla.json.rb
@@ -12,8 +12,8 @@ message = Mailbox.find(@message)
@from.untaint if @from =~ /\A("?[\s\w]+"?\s+<)?\w+@apache\.org>?\z/
-# extract file extension (only needed if there is no signature)
-fileext = File.extname(@selected).downcase if @signature.empty?
+# extract file extension
+fileext = File.extname(@selected).downcase
# verify that an ICLA under that name doesn't already exist
if "#@filename#{fileext}" =~ /\A\w[-\w]*\.?\w*\z/
@@ -45,49 +45,18 @@ _personalize_email(env.user)
@valid_user = (@user =~ /^[a-z][a-z0-9]{2,}$/)
@valid_user &&= !(ASF::ICLA.taken?(@user) or ASF::Mail.taken?(@user))
+# initialize commit message
+@document = "ICLA for #{@pubname}"
+
########################################################################
# document/iclas #
+# officers/iclas.txt #
########################################################################
# write attachment (+ signature, if present) to the documents/iclas directory
-task "svn commit documents/iclas/#@filename#{fileext}" do
- form do
- _input value: URI.decode(@selected), name: 'selected'
-
- if @signature and not @signature.empty?
- _input value: @signature, name: 'signature'
- end
- end
+task "svn commit documents/iclas/#@filename#{fileext} and iclas.txt" do
- complete do |dir|
- # checkout empty directory
- svn 'checkout', '--depth', 'empty',
- ASF::SVN.svnurl('iclas'), "#{dir}/iclas"
-
- # create/add file(s)
- if @signature.to_s.empty? or fileext != '.pdf'
- message.write_svn("#{dir}/iclas", @filename, URI.decode(@selected), @signature)
- else
- message.write_svn("#{dir}/iclas", @filename,
- @selected => 'icla.pdf', @signature => 'icla.pdf.asc')
- end
-
- # Show files to be added
- svn 'status', "#{dir}/iclas"
-
- # commit changes
- svn 'commit', "#{dir}/iclas/#{@filename}#{fileext}",
- '-m', "ICLA from #{@pubname}"
- end
-end
-
-########################################################################
-# officers/iclas.txt #
-########################################################################
-
-# insert line into iclas.txt
-task "svn commit foundation/officers/iclas.txt" do
- # construct line to be inserted
+ # construct line to be inserted in iclas.txt
@iclaline ||= [
'notinavail',
@realname.strip,
@@ -97,29 +66,26 @@ task "svn commit foundation/officers/iclas.txt" do
].join(':')
form do
+ _input value: @selected, name: 'selected'
+
+ if @signature and not @signature.empty?
+ _input value: @signature, name: 'signature'
+ end
+
_input value: @iclaline, name: 'iclaline'
+
+ _input value: @filename
end
complete do |dir|
- # checkout empty officers directory
- svn 'checkout', '--depth', 'empty',
- ASF::SVN.svnurl!('officers'),
- File.join(dir, 'officers')
-
- # retrieve iclas.txt
- dest = File.join(dir, 'officers', 'iclas.txt')
- svn 'update', dest
- # update iclas.txt
- iclas_txt = ASF::ICLA.sort(File.read(dest) + @iclaline + "\n")
- File.write dest, iclas_txt
-
- # show the changes
- svn 'diff', dest
+ svn_multi('officers', 'iclas.txt', 'iclas', @selected, @signature, @filename, fileext, message, @document) do |input|
+ # append entry to iclas.txt
+ ASF::ICLA.sort(input + @iclaline + "\n")
+ end
- # commit changes
- svn 'commit', dest, '-m', "ICLA for #{@pubname}"
end
+
end
########################################################################
@@ -163,7 +129,7 @@ task "email #@email" do
@cttee = "Apache #{@podling.display_name} podling" if @podling
# build mail from template
mail = message.reply(
- subject: "ICLA for #{@pubname}",
+ subject: @document,
from: @from,
to: "#{@pubname.inspect} <#{@email}>",
cc: [