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 c89917a  make an attempt to guess at what the count will be
c89917a is described below

commit c89917a4d184a238e7dee0e0a73149ca9e1741e4
Author: Sam Ruby <[email protected]>
AuthorDate: Thu Jan 2 16:56:10 2020 -0500

    make an attempt to guess at what the count will be
---
 www/secretary/workbench/views/actions/icla2.json.rb | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/www/secretary/workbench/views/actions/icla2.json.rb 
b/www/secretary/workbench/views/actions/icla2.json.rb
index 899eeba..6dcc0de 100644
--- a/www/secretary/workbench/views/actions/icla2.json.rb
+++ b/www/secretary/workbench/views/actions/icla2.json.rb
@@ -58,8 +58,24 @@ end
 #                          file new document                           #
 ########################################################################
 
+# determine what the counter is likely to be by querying the server
+# Notes:
+#   - ASF::SVN.list returns 
+#     - a string with "\n" separators
+#     - If there is an error ASF::SVN.list returns an array with nil
+#       as the first entry.
+#   - Converting the results to an array, extracting the first entry,
+#     coorsing it to a string, and then splitting it will result in an array
+#   - calling .max on an empty array returns nil.  Treat it as one as there
+#     is an existing document that will be moved into this directory.
+#   - If all else fails, set count to "N"
+count = (Array(ASF::SVN.list(ASF::SVN.svnurl('iclas') + '/' + @filename)).
+      first.to_s.split.
+      map {|name| name[/.*(\d+)\./, 1] || 1}.
+      map(&:to_i).max || 1) + 1 rescue 'N'
+
 # write attachment (+ signature, if present) to the documents/iclas directory
-task "svn commit documents/iclas/#@filename/iclaN#{fileext}" do
+task "svn commit documents/iclas/#@filename/iclaN#{count}{fileext}" do
   form do
     _input value: @selected, name: 'selected'
 

Reply via email to