diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 18:09:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 18:09:44 +0000 |
commit | 2c156e3c7bbade01c36eee18327f1ced6eebea79 (patch) | |
tree | 115fa8dbf6bc05037378b380311d31acb805f54c /lib/gitlab/ci/reports | |
parent | 8e129497b2565b8c595ef4f806d9a9595ca654e5 (diff) | |
download | gitlab-ce-2c156e3c7bbade01c36eee18327f1ced6eebea79.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/reports')
-rw-r--r-- | lib/gitlab/ci/reports/coverage_reports.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/gitlab/ci/reports/coverage_reports.rb b/lib/gitlab/ci/reports/coverage_reports.rb new file mode 100644 index 00000000000..31afb636d2f --- /dev/null +++ b/lib/gitlab/ci/reports/coverage_reports.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Gitlab + module Ci + module Reports + class CoverageReports + attr_reader :files + + def initialize + @files = {} + end + + def pick(keys) + coverage_files = files.select do |key| + keys.include?(key) + end + + { files: coverage_files } + end + + def add_file(name, line_coverage) + if files[name].present? + line_coverage.each { |line, hits| combine_lines(name, line, hits) } + + else + files[name] = line_coverage + end + end + + private + + def combine_lines(name, line, hits) + if files[name][line].present? + files[name][line] += hits + + else + files[name][line] = hits + end + end + end + end + end +end |