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/23 13:43:35 UTC

[whimsy] branch master updated: Simplify by using library routine

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 89a78cd  Simplify by using library routine
89a78cd is described below

commit 89a78cd7f45e4dbb823c78ed98030eb9cf23a1dc
Author: Sebb <se...@apache.org>
AuthorDate: Thu Jul 23 14:43:25 2020 +0100

    Simplify by using library routine
---
 .../workbench/views/actions/memapp.json.rb         | 41 +++++-----------------
 1 file changed, 8 insertions(+), 33 deletions(-)

diff --git a/www/secretary/workbench/views/actions/memapp.json.rb b/www/secretary/workbench/views/actions/memapp.json.rb
index d9e7a18..4cf5a4e 100644
--- a/www/secretary/workbench/views/actions/memapp.json.rb
+++ b/www/secretary/workbench/views/actions/memapp.json.rb
@@ -135,20 +135,8 @@ task "subscribe to members@apache.org" do
     fn = "#{@availid}-members-#{Time.now.strftime '%Y%m%d-%H%M%S-%L'}.json"
     fn.untaint if @availid =~ /^\w[-.\w]+$/
 
-    # checkout empty directory
-    svn 'checkout', '--depth', 'empty',
-      ASF::SVN.svnpath!('subreq'),
-      "#{dir}/subreq"
-
-    # write out subscription request
-    File.write "#{dir}/subreq/#{fn}", @subreq
-    svn 'add', "#{dir}/subreq/#{fn}"
-
-    # Show changes
-    svn 'diff', "#{dir}/subreq"
-
-    # commit changes
-    svn 'commit', "#{dir}/subreq", '-m', @document
+    rc = ASF::SVN.create_(ASF::SVN.svnurl!('subreq'), fn, @subreq, @document, env, _)
+    raise RuntimeError.new("exit code: #{rc}") if rc != 0
   end
 end
 
@@ -175,26 +163,13 @@ task "svn commit memapp-received.text" do
   end
 
   complete do |dir|
-    # checkout empty directory
     meeting = file.split('/')[-2]
-    svn 'checkout', '--depth', 'empty',
-      ASF::SVN.svnpath!('Meetings', meeting),
-      File.join(dir, meeting)
-
-    # retrieve memapp-received.txt
-    dest = "#{dir}/#{meeting}/memapp-received.txt"
-    svn 'update', dest
-
-    # create/add file(s)
-    received = File.read(dest)
-    received[/.*\s#{@availid}\s.*/] = @line
-    File.write(dest, received)
-
-    # Show changes
-    svn 'diff', "#{dir}/#{meeting}"
-
-    # commit changes
-    svn 'commit', "#{dir}/#{meeting}/memapp-received.txt", '-m', @document
+    path = ASF::SVN.svnpath!('Meetings', meeting,'memapp-received.txt')
+    rc = ASF::SVN.update(path, @document, env, _, {diff: true}) do |tmpdir, input|
+      input[/.*\s#{@availid}\s.*/] = @line
+      input
+    end
+    raise RuntimeError.new("exit code: #{rc}") if rc != 0
   end
 end