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/18 21:08:03 UTC
[whimsy] branch master updated: WHIMSY-336 atomic commits
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 c7eed7f WHIMSY-336 atomic commits
c7eed7f is described below
commit c7eed7f20cf987feffcd23be633b5a71ad334324
Author: Sebb <se...@apache.org>
AuthorDate: Sat Jul 18 22:07:53 2020 +0100
WHIMSY-336 atomic commits
Fix cclas.json.rb to perform an atomic commit for
documents/cclas and foundation/officers/cclas.txt
---
www/secretary/workbench/views/actions/ccla.json.rb | 70 +++++++++-------------
1 file changed, 29 insertions(+), 41 deletions(-)
diff --git a/www/secretary/workbench/views/actions/ccla.json.rb b/www/secretary/workbench/views/actions/ccla.json.rb
index 54f88b3..952fcf0 100644
--- a/www/secretary/workbench/views/actions/ccla.json.rb
+++ b/www/secretary/workbench/views/actions/ccla.json.rb
@@ -33,67 +33,55 @@ _personalize_email(env.user)
@document = "CCLA from #{@company}"
########################################################################
-# document/cclas #
+# document/cclas and cclas.txt #
########################################################################
-# write attachment (+ signature, if present) to the documents/cclas directory
-task "svn commit documents/cclas/#@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('cclas'), "#{dir}/cclas"
-
- # create/add file(s)
- dest = message.write_svn("#{dir}/cclas", @filename, @selected, @signature)
-
- # Show files to be added
- svn 'status', "#{dir}/cclas"
-
- # commit changes
- svn 'commit', "#{dir}/cclas/#{@filename}#{fileext}", '-m', @document
- end
-end
-
-########################################################################
-# officers/cclas.txt #
-########################################################################
-
-# insert line into cclas.txt
-task "svn commit foundation/officers/cclas.txt" do
- # construct line to be inserted
+task "svn commit documents/cclas/#@filename#{fileext} and update cclas.txt" do
+
+ # construct line to be inserted in cclas.txt
@cclalines = "notinavail:" + @company.strip
-
unless @contact.empty?
@cclalines += " - #{@contact.strip}"
end
-
@cclalines += ":#{@email.strip}:Signed Corp CLA"
-
unless @employees.empty?
@cclalines += " for #{@employees.strip.gsub(/\s*\n\s*/, ', ')}"
end
-
unless @product.empty?
@cclalines += " for #{@product.strip}"
end
form do
+ _input value: @selected, name: 'selected'
+
+ if @signature and not @signature.empty?
+ _input value: @signature, name: 'signature'
+ end
+
_input value: @cclalines, name: 'cclalines'
end
complete do |dir|
- path = ASF::SVN.svnpath!('officers', 'cclas.txt')
- ASF::SVN.update(path, @document, env, _, {diff: true}) do |tmpdir, contents|
- contents + @cclalines + "\n"
+ ASF::SVN.multiUpdate_(ASF::SVN.svnpath!('officers', 'cclas.txt'), @document, env, _) do |text|
+
+ extras = []
+ # write the file(s)
+ dest = message.write_att(@selected, @signature)
+
+ if dest.size > 1 # write to a container directory
+ container = ASF::SVN.svnpath!('cclas', @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!('cclas',"#{@filename}#{fileext}")]
+ end
+
+ [text + @cclalines + "\n", extras]
end
+
end
end