summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-02-26 13:42:25 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-02-26 16:06:49 +0200
commit3337130e015fba1d04a53e8e3a7098f966792f5f (patch)
tree291efd83a493c79fe9d0296b68dfa88c7ac9f0a2
parent84097def3c97f0e0d8993ff07375c89e4b91aea8 (diff)
downloadgitlab-ce-3337130e015fba1d04a53e8e3a7098f966792f5f.tar.gz
Use Gitlab::Popen instead of spawn [ci skip]
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--lib/gitlab/plugin.rb19
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/gitlab/plugin.rb b/lib/gitlab/plugin.rb
index be5d6d6b1c1..5339c4dbbc8 100644
--- a/lib/gitlab/plugin.rb
+++ b/lib/gitlab/plugin.rb
@@ -13,24 +13,11 @@ module Gitlab
end
def self.execute(file, data)
- # Prepare the hook subprocess. Attach a pipe to its stdin, and merge
- # both its stdout and stderr into our own stdout.
- stdin_reader, stdin_writer = IO.pipe
- hook_pid = spawn({}, file, in: stdin_reader, err: :out)
- stdin_reader.close
-
- # Submit changes to the hook via its stdin.
- begin
- IO.copy_stream(StringIO.new(data.to_json), stdin_writer)
- rescue Errno::EPIPE
- # It is not an error if the hook does not consume all of its input.
+ _output, exit_status = Gitlab::Popen.popen([file]) do |stdin|
+ stdin.write(data.to_json)
end
- # Close the pipe to let the hook know there is no further input.
- stdin_writer.close
-
- Process.wait(hook_pid)
- $?.success?
+ exit_status.zero?
end
end
end