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/19 23:55:08 UTC
[whimsy] branch master updated: WHIMSY-336 atomic commit
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 83ac324 WHIMSY-336 atomic commit
83ac324 is described below
commit 83ac324976415ac1a877b88b15729ab1c6dcac98
Author: Sebb <se...@apache.org>
AuthorDate: Mon Jul 20 00:54:58 2020 +0100
WHIMSY-336 atomic commit
---
.../workbench/views/actions/grant.json.rb | 85 +++++++++-------------
1 file changed, 35 insertions(+), 50 deletions(-)
diff --git a/www/secretary/workbench/views/actions/grant.json.rb b/www/secretary/workbench/views/actions/grant.json.rb
index 9e5d54c..3338c9f 100644
--- a/www/secretary/workbench/views/actions/grant.json.rb
+++ b/www/secretary/workbench/views/actions/grant.json.rb
@@ -33,71 +33,56 @@ _personalize_email(env.user)
@document = "Software Grant from #{@company}"
########################################################################
-# document/grants #
+# document/grants & officers/grants.txt #
########################################################################
# write attachment (+ signature, if present) to the documents/grants directory
-task "svn commit documents/grants/#@filename#{fileext}" do
- form do
- _input value: @selected, name: 'selected'
-
- if @signature and not @signature.empty?
- _input value: @signature, name: 'signature'
- end
- end
-
- complete do |dir|
- # checkout empty directory
- svn 'checkout', '--depth', 'empty',
- ASF::SVN.svnurl('grants'), "#{dir}/grants"
-
- # create/add file(s)
- dest = message.write_svn("#{dir}/grants", @filename, @selected, @signature)
-
- # Show files to be added
- svn 'status', "#{dir}/grants"
-
- # commit changes
- svn 'commit', "#{dir}/grants/#{@filename}#{fileext}", '-m', @document
- end
-end
+task "svn commit documents/grants/#@filename#{fileext} and update grants.txt" do
-########################################################################
-# officers/grants.txt #
-########################################################################
-
-# insert line into grants.txt
-task "svn commit foundation/officers/grants.txt" do
# construct line to be inserted
@grantlines = "#{@company.strip}" +
"\n file: #{@filename}#{fileext}" +
"\n for: #{@description.strip.gsub(/\r?\n\s*/,"\n ")}"
form do
+ _input value: @selected, name: 'selected'
+
+ if @signature and not @signature.empty?
+ _input value: @signature, name: 'signature'
+ end
+
_textarea @grantlines, name: 'grantlines',
rows: @grantlines.split("\n").length
end
complete do |dir|
- # checkout empty officers directory
- svn 'checkout', '--depth', 'empty',
- ASF::SVN.svnurl!('officers'),
- File.join(dir, 'officers')
-
- # retrieve grants.txt
- dest = File.join(dir, 'officers', 'grants.txt')
- svn 'update', dest
-
- # update grants.txt
- marker = "\n# registering. documents on way to Secretary.\n"
- File.write dest,
- File.read(dest).split(marker).insert(1, "\n#{@grantlines}\n", marker).join
-
- # show the changes
- svn 'diff', dest
-
- # commit changes
- svn 'commit', dest, '-m', @document
+ ASF::SVN.multiUpdate_(ASF::SVN.svnpath!('officers', 'grants.txt'), @document, env, _) do |input|
+
+ extras = []
+
+ # write the file(s)
+ dest = message.write_att(@selected, @signature)
+
+ if dest.size > 1 # write to a container directory
+ unless @filename =~ /\A[a-zA-Z][-.\w]+\z/
+ raise IOError.new("invalid filename: #{@filename}")
+ end
+ container = ASF::SVN.svnpath!('grants', @filename)
+ extras << ['mkdir', container]
+ dest.each do |name, path|
+ extras << ['put', path, File.join(container, name)]
+ end
+ else
+ name, path = dest.flatten
+ extras << ['put', path, ASF::SVN.svnpath!('grants',"#{@filename}#{fileext}")]
+ end
+
+ # update grants.txt
+ marker = "\n# registering. documents on way to Secretary.\n"
+ out = input.split(marker).insert(1, "\n#{@grantlines}\n", marker).join
+
+ [out, extras]
+ end
end
end