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/10 13:58:49 UTC

[whimsy] branch master updated: Implement svn_! for handling _.system! ['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 d24756b  Implement svn_! for handling _.system! ['svn'...]
d24756b is described below

commit d24756b4105580726048c44bda222450304fa900
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jun 10 14:58:40 2020 +0100

    Implement svn_! for handling _.system! ['svn'...]
---
 lib/spec/lib/svn_wunderbar_spec.rb | 36 ++++++++++++++++++++++++++++++++++++
 lib/whimsy/asf/svn.rb              |  7 +++++++
 2 files changed, 43 insertions(+)

diff --git a/lib/spec/lib/svn_wunderbar_spec.rb b/lib/spec/lib/svn_wunderbar_spec.rb
index 0f0de19..b3ceb7e 100644
--- a/lib/spec/lib/svn_wunderbar_spec.rb
+++ b/lib/spec/lib/svn_wunderbar_spec.rb
@@ -5,6 +5,31 @@ require 'spec_helper'
 require 'whimsy/asf'
 require 'wunderbar'
 
+describe "ASF::SVN.svn_!" do
+  it "svn_!('info') should return array with Name:" do
+    repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
+
+    rc, out = _json do |_|
+      ASF::SVN.svn_!('info', repo, _)
+    end
+
+    expect(rc).to be(0)
+    expect(out['transcript'].class).to equal(Array)
+    expect(out['transcript'].include?('Name: _template.xml')).to be(true)
+  end
+  it "svn_!('info', 'no file') should fail with E200009" do
+    repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'___')
+
+    rc, out = _json do |_|
+      ASF::SVN.svn_!('info', repo, _)
+    end
+
+    expect(rc).to be(nil)
+    expect(out['transcript'].class).to equal(Array)
+    expect(out['transcript'].join("\n")).to match(/svn: E200009:/)
+  end
+end
+
 describe "ASF::SVN.svn_" do
   it "svn_('info') should return array with Name:" do
     repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
@@ -29,6 +54,17 @@ describe "ASF::SVN.svn_" do
     exp = ["svn", "info", "--non-interactive", "--", "https://svn.apache.org/repos/asf/attic/site/xdocs/projects/_template.xml"]
     expect(out['transcript'][1]).to eq(exp.inspect)
   end
+  it "svn_('info', 'no file') should fail with E200009" do
+    repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'___')
+
+    rc, out = _json do |_|
+      ASF::SVN.svn_('info', repo, _)
+    end
+
+    expect(rc).to be(1)
+    expect(out['transcript'].class).to equal(Array)
+    expect(out['transcript'].join("\n")).to match(/svn: E200009:/)
+  end
 end
 
 describe "ASF::SVN.update" do
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index d7cda25..8c7dc1d 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -415,6 +415,13 @@ module ASF
       _.system cmd
     end
 
+    # As for self.svn_, but failures cause a RuntimeError
+    def self.svn_!(command, path, _, options = {})
+      rc = self.svn_(command, path, _, options = options)
+      raise RuntimeError.new("exit code: #{rc}") if rc != 0
+      rc
+    end
+
     # retrieve revision, [err] for a path in svn
     def self.getRevision(path, user=nil, password=nil)
       out, err = getInfo(path, user, password)