diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-01-04 21:43:06 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-05 03:09:28 +0300 |
commit | a00578ce5cdf4bab95990bca9e806c6322bb1384 (patch) | |
tree | 5aafe058fa55086038dbb3086121ad624447c0e4 /lib/gitlab/git/popen.rb | |
parent | aec04a47c16665f1dfb1fb61647c3f78a4dde20f (diff) |
Absorb gitlab_git
Diffstat (limited to 'lib/gitlab/git/popen.rb')
-rw-r--r-- | lib/gitlab/git/popen.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/git/popen.rb b/lib/gitlab/git/popen.rb new file mode 100644 index 00000000000..df9ca3ee5ac --- /dev/null +++ b/lib/gitlab/git/popen.rb @@ -0,0 +1,26 @@ +require 'open3' + +module Gitlab + module Git + module Popen + def popen(cmd, path) + unless cmd.is_a?(Array) + raise "System commands must be given as an array of strings" + end + + vars = { "PWD" => path } + options = { chdir: path } + + @cmd_output = "" + @cmd_status = 0 + Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| + @cmd_output << stdout.read + @cmd_output << stderr.read + @cmd_status = wait_thr.value.exitstatus + end + + [@cmd_output, @cmd_status] + end + end + end +end |