Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-01-27 20:39:58 +0300
committerJacob Vosmaer <jacob@gitlab.com>2017-01-27 20:39:58 +0300
commitf0ac68af338a1f04aa806539e83bc46246346b26 (patch)
treedb3356779176015f3af10ae7f0669e5ce221ceed /_support/run.rb
parentaeaa31585314c490054adc1c082abe7b79fa15cc (diff)
Add capture! method to run.rb
Diffstat (limited to '_support/run.rb')
-rw-r--r--_support/run.rb28
1 files changed, 25 insertions, 3 deletions
diff --git a/_support/run.rb b/_support/run.rb
index 8d6ea482e..121729b32 100644
--- a/_support/run.rb
+++ b/_support/run.rb
@@ -1,7 +1,29 @@
def run!(cmd, chdir='.')
- print_cmd = cmd.join(' ')
- puts "-> #{print_cmd}"
+ GitalySupport.print_cmd(cmd)
if !system(*cmd, chdir: chdir)
- abort "command failed: #{print_cmd}"
+ GitalySupport.fail_cmd!(cmd)
+ end
+end
+
+def capture!(cmd, chdir='.')
+ GitalySupport.print_cmd(cmd)
+ output = IO.popen(cmd, chdir: chdir) { |io| io.read }
+ fail_cmd!(cmd) unless $?.success?
+ output
+end
+
+module GitalySupport
+ class << self
+ def print_cmd(cmd)
+ puts '-> ' + printable_cmd(cmd)
+ end
+
+ def fail_cmd!(cmd)
+ abort "command failed: #{printable_cmd(cmd)}"
+ end
+
+ def printable_cmd(cmd)
+ cmd.join(' ')
+ end
end
end