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 7503c04  Simplify by using existing methods
7503c04 is described below

commit 7503c04461be19a2c19d52014728d98d763a562d
Author: Sebb <s...@apache.org>
AuthorDate: Sat Jun 6 15:58:00 2020 +0100

    Simplify by using existing methods
---
 lib/whimsy/asf/svn.rb | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 9af5dbb..c9a73e1 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -341,31 +341,15 @@ module ASF
     end
 
     # retrieve revision, content for a file in svn
+    # N.B. There is a window between fetching the revision and getting the 
file contents
     def self.get(path, user=nil, password=nil)
-      # build svn info command
-      cmd = ['svn', 'info', path, '--non-interactive']
-
-      # password was supplied, add credentials
-      if password
-        cmd += ['--username', user, '--password', password, '--no-auth-cache']
-      end
-
-      # default the values to return
-      revision = '0'
-      content = nil
-
-      # issue svn info command
-      stdout, status = Open3.capture2(*cmd)
-      if status.success?
-        # extract revision number
-        revision = stdout[/^Revision: (\d+)/, 1]
-
-        # extract contents
-        cmd[1] = 'cat'
-        content, status = Open3.capture2(*cmd)
+      revision, _ = self.getInfoItem(path, 'revision', {user: user, password: 
password})
+      if revision
+        content, _ = self.svn('cat', path, {user: user, password: password})
+      else
+        revision = '0'
+        content = nil
       end
-
-      # return results
       return revision, content
     end
 

Reply via email to