summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-04-11 21:10:12 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-04-12 12:03:39 +0200
commit23fbbe0c921ab3c878164d49316c4ce82b2035fb (patch)
treee2222ccadba40a2a351556668e808e2c8a5c640d /lib
parent069c54a7d7a1d1d6ec1dc48c4212139eff6735df (diff)
downloadgitlab-ce-23fbbe0c921ab3c878164d49316c4ce82b2035fb.tar.gz
Return nil as coverage instead of a File objectzj-fix-coverage-bug
Given a valid pipeline job, and a regex which wouldn't match to a jobs trace, the stream of the trace would return the File object. This was not the case when it matched a value, as that would have been return from the block. Now the `extract_coverage` method returns `nil` if no match was found.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/trace/stream.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb
index 2af94e2c60e..41dcf846fed 100644
--- a/lib/gitlab/ci/trace/stream.rb
+++ b/lib/gitlab/ci/trace/stream.rb
@@ -76,11 +76,14 @@ module Gitlab
stream.each_line do |line|
matches = line.scan(regex)
next unless matches.is_a?(Array)
+ next if matches.empty?
match = matches.flatten.last
coverage = match.gsub(/\d+(\.\d+)?/).first
- return coverage.to_f if coverage.present?
+ return coverage if coverage.present?
end
+
+ nil
rescue
# if bad regex or something goes wrong we dont want to interrupt transition
# so we just silentrly ignore error for now