summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-01-24 21:05:01 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-01-26 19:42:48 +0800
commita2618310aea7d58e52d2d29ec4871e27717eb0f0 (patch)
tree63c943c0cd428e82955574f578ef55b5c166f1e6 /lib
parent0bf918f05e827b380107d88f4592d1ceedd632f9 (diff)
downloadgitlab-ce-a2618310aea7d58e52d2d29ec4871e27717eb0f0.tar.gz
Use Process::Status rather than an integer
However keep backward compatibility
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/popen.rb6
-rw-r--r--lib/gitlab/popen/runner.rb12
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb
index 05526a9ac94..b9832a724c4 100644
--- a/lib/gitlab/popen.rb
+++ b/lib/gitlab/popen.rb
@@ -11,7 +11,7 @@ module Gitlab
def popen(cmd, path = nil, vars = {}, &block)
result = popen_with_detail(cmd, path, vars, &block)
- [result.stdout << result.stderr, result.status]
+ [result.stdout << result.stderr, result.status&.exitstatus]
end
# Returns Result
@@ -30,7 +30,7 @@ module Gitlab
cmd_stdout = ''
cmd_stderr = ''
- cmd_status = 0
+ cmd_status = nil
start = Time.now
Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
@@ -39,7 +39,7 @@ module Gitlab
cmd_stdout = stdout.read
cmd_stderr = stderr.read
- cmd_status = wait_thr.value.exitstatus
+ cmd_status = wait_thr.value
end
Result.new(cmd, cmd_stdout, cmd_stderr, cmd_status, Time.now - start)
diff --git a/lib/gitlab/popen/runner.rb b/lib/gitlab/popen/runner.rb
index 36284134707..f44035a48bb 100644
--- a/lib/gitlab/popen/runner.rb
+++ b/lib/gitlab/popen/runner.rb
@@ -20,12 +20,12 @@ module Gitlab
end
end
- def all_good?
- all_status_zero? && all_stderr_empty?
+ def all_success_and_clean?
+ all_success? && all_stderr_empty?
end
- def all_status_zero?
- results.all? { |result| result.status.zero? }
+ def all_success?
+ results.all? { |result| result.status.success? }
end
def all_stderr_empty?
@@ -33,12 +33,12 @@ module Gitlab
end
def failed_results
- results.select { |result| result.status.nonzero? }
+ results.reject { |result| result.status.success? }
end
def warned_results
results.select do |result|
- result.status.zero? && !result.stderr.empty?
+ result.status.success? && !result.stderr.empty?
end
end
end