Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/usage_data_counters/ci_template_unique_counter.rb')
-rw-r--r--lib/gitlab/usage_data_counters/ci_template_unique_counter.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
index 61c071c8738..1e8918c7c96 100644
--- a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
+++ b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
@@ -34,6 +34,21 @@ module Gitlab::UsageDataCounters
Gitlab::Template::GitlabCiYmlTemplate.find(template_name.chomp('.gitlab-ci.yml'))&.full_name
end
+ def all_included_templates(template_name)
+ expanded_template_name = expand_template_name(template_name)
+ results = [expanded_template_name].tap do |result|
+ template = Gitlab::Template::GitlabCiYmlTemplate.find(template_name.chomp('.gitlab-ci.yml'))
+ data = YAML.safe_load(template.content, aliases: true)
+ [data['include']].compact.flatten.each do |ci_include|
+ if ci_include_template = ci_include['template']
+ result.concat(all_included_templates(ci_include_template))
+ end
+ end
+ end
+
+ results.uniq.sort_by { _1['name'] }
+ end
+
private
def template_to_event_name(template)