diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 18:08:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 18:08:51 +0300 |
commit | 163a7046ac76eb4109184e82ce0af911633e6626 (patch) | |
tree | 9f22bb438db435d518e8f5520b309c6319ae0bd8 /lib/gitlab/template | |
parent | 0637ba1e6e9024f35b2cbf561d9002ec17350bb3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/template')
-rw-r--r-- | lib/gitlab/template/finders/global_template_finder.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/template/gitlab_ci_yml_template.rb | 11 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/gitlab/template/finders/global_template_finder.rb b/lib/gitlab/template/finders/global_template_finder.rb index 2dd4b7a4092..3669d652fd3 100644 --- a/lib/gitlab/template/finders/global_template_finder.rb +++ b/lib/gitlab/template/finders/global_template_finder.rb @@ -5,9 +5,11 @@ module Gitlab module Template module Finders class GlobalTemplateFinder < BaseTemplateFinder - def initialize(base_dir, extension, categories = {}) + def initialize(base_dir, extension, categories = {}, exclusions: []) @categories = categories @extension = extension + @exclusions = exclusions + super(base_dir) end @@ -16,6 +18,8 @@ module Gitlab end def find(key) + return if excluded?(key) + file_name = "#{key}#{@extension}" # The key is untrusted input, so ensure we can't be directed outside @@ -28,11 +32,20 @@ module Gitlab def list_files_for(dir) dir = "#{dir}/" unless dir.end_with?('/') - Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) } + + Dir.glob(File.join(dir, "*#{@extension}")).select do |f| + next if excluded?(f) + + f =~ self.class.filter_regex(@extension) + end end private + def excluded?(file_name) + @exclusions.include?(file_name) + end + def select_directory(file_name) @categories.keys.find do |category| File.exist?(File.join(category_directory(category), file_name)) diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb index ee91f1200cd..26a9dc9fd38 100644 --- a/lib/gitlab/template/gitlab_ci_yml_template.rb +++ b/lib/gitlab/template/gitlab_ci_yml_template.rb @@ -17,16 +17,25 @@ module Gitlab { 'General' => '', 'Pages' => 'Pages', + 'Verify' => 'Verify', 'Auto deploy' => 'autodeploy' } end + def disabled_templates + %w[ + Verify/Browser-Performance + ] + end + def base_dir Rails.root.join('lib/gitlab/ci/templates') end def finder(project = nil) - Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories) + Gitlab::Template::Finders::GlobalTemplateFinder.new( + self.base_dir, self.extension, self.categories, exclusions: self.disabled_templates + ) end end end |