You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/09/30 00:47:33 UTC

[whimsy] branch master updated: rename attachment and signature if there is a signature

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  957314e   rename attachment and signature if there is a signature
957314e is described below

commit 957314eb25de9b290ebddb26da92f6b600c32abb
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 29 20:46:53 2016 -0400

    rename attachment and signature if there is a signature
---
 www/secmail/models/attachment.rb       |  4 ++--
 www/secmail/models/message.rb          | 10 +++++++---
 www/secmail/views/actions/icla.json.rb |  7 ++++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/www/secmail/models/attachment.rb b/www/secmail/models/attachment.rb
index ce2733d..ee2dcba 100644
--- a/www/secmail/models/attachment.rb
+++ b/www/secmail/models/attachment.rb
@@ -67,9 +67,9 @@ class Attachment
   end
 
   # write a file out to svn
-  def write_svn(repos, file)
+  def write_svn(repos, file, path=nil)
     filename = File.join(repos, file)
-    filename = File.join(filename, safe_name) if Dir.exist? filename
+    filename = File.join(filename, path || safe_name) if Dir.exist? filename
 
     raise Errno::EEXIST.new(file) if File.exist? filename
     File.write filename, body, encoding: Encoding::BINARY
diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index 84f626a..40e9139 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -152,9 +152,13 @@ class Message
   # write one or more attachments to directory containing an svn checkout
   #
   def write_svn(repos, filename, *attachments)
+    # drop all nil and empty values
     attachments = attachments.flatten.reject {|name| name.to_s.empty?}
 
-    if attachments.length == 1
+    # if last argument is a Hash, treat it as name/value pairs
+    attachments += attachments.pop.to_a if Hash === attachments.last
+
+    if attachments.flatten.length == 1
       ext = File.extname(attachments.first).untaint
       find(attachments.first).write_svn(repos, filename + ext)
     else
@@ -171,8 +175,8 @@ class Message
       Dir.mkdir dest
 
       # write out selected attachment
-      attachments.each do |attachment|
-        find(attachment).write_svn(repos, filename)
+      attachments.each do |attachment, basename|
+        find(attachment).write_svn(repos, filename, basename)
       end
 
       Kernel.system 'svn', 'add', dest
diff --git a/www/secmail/views/actions/icla.json.rb b/www/secmail/views/actions/icla.json.rb
index 81d9f02..3ae28bd 100644
--- a/www/secmail/views/actions/icla.json.rb
+++ b/www/secmail/views/actions/icla.json.rb
@@ -47,7 +47,12 @@ task "svn commit documents/iclas/#@filename#{fileext}" do
       'https://svn.apache.org/repos/private/documents/iclas', "#{dir}/iclas"
 
     # create/add file(s)
-    dest = message.write_svn("#{dir}/iclas", @filename, @selected, @signature)
+    if @signature.to_s.empty?
+      dest = message.write_svn("#{dir}/iclas", @filename, @selected)
+    else
+      dest = message.write_svn("#{dir}/iclas", @filename, 
+        @selected => 'icla.pdf', @signature => 'icla.pdf.asc')
+    end
 
     # Show files to be added
     svn 'status', "#{dir}/iclas"

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].