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/06/09 22:03:01 UTC

[whimsy] branch master updated: Support multiple paths in svn()

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 6ea4edc  Support multiple paths in svn()
6ea4edc is described below

commit 6ea4edccd290b218e6836ce11fba8f275fba2951
Author: Sebb <se...@apache.org>
AuthorDate: Tue Jun 9 23:02:51 2020 +0100

    Support multiple paths in svn()
---
 lib/spec/lib/svn_spec.rb | 18 ++++++++++++++++++
 lib/whimsy/asf/svn.rb    | 12 ++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/lib/spec/lib/svn_spec.rb b/lib/spec/lib/svn_spec.rb
index 0954c93..d020851 100644
--- a/lib/spec/lib/svn_spec.rb
+++ b/lib/spec/lib/svn_spec.rb
@@ -232,4 +232,22 @@ describe ASF::SVN do
     end
   end
 
+  describe "ASF::SVN.svn" do
+    it "svn('info', path) should return 'Name: path'" do
+      repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
+      out, err = ASF::SVN.svn('info',repo)
+      expect(out).to match(/^Name: _template.xml$/)
+    end
+    it "svn('info', [path]) should return 'Name: path'" do
+      repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
+      out, err = ASF::SVN.svn('info',[repo])
+      expect(out).to match(/^Name: _template.xml$/)
+    end
+    it "svn('info', [path1, path2], {args: ['--show-item','kind']}) should return 'file ...'" do
+      path1 = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
+      path2 = File.join(ASF::SVN.svnurl('attic-xdocs'),'jakarta.xml')
+      out, err = ASF::SVN.svn('info',[path1, path2], {args: ['--show-item','kind']})
+      expect(out).to match(/^file +https:/)
+    end
+  end
 end
\ No newline at end of file
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index d029b80..5f766b0 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -266,7 +266,7 @@ module ASF
     # low level SVN command
     # params:
     # command - info, list etc
-    # path - the path to be used
+    # path - the path(s) to be used - String or Array of Strings
     # options - hash of:
     #  :args - string or array of strings, e.g. '-v', ['--depth','empty']
     #  :env - environment: source for user and password
@@ -285,7 +285,7 @@ module ASF
       end
 
       # build svn command
-      cmd = ['svn', command, path, '--non-interactive']
+      cmd = ['svn', command, '--non-interactive']
 
       args = options[:args]
       if args
@@ -318,6 +318,14 @@ module ASF
         end
       end
 
+      cmd << '--' # ensure paths cannot be mistaken for options
+
+      if path.is_a? Array
+        cmd += path
+      else
+        cmd << path
+      end
+
       p cmd if options[:verbose]
 
       # issue svn command