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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-20 00:10:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-20 00:10:45 +0300
commitf265a70317c69af9d955d9a4c303b0bbcb8261ee (patch)
treefc8d8bd0d82dd713faa94fcab40235667f9267c4 /lib/gitlab/template
parent83e4339a328c1a8c8e232d06f7d5e49c6e699fba (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.rb7
-rw-r--r--lib/gitlab/template/gitlab_ci_yml_template.rb12
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/gitlab/template/finders/global_template_finder.rb b/lib/gitlab/template/finders/global_template_finder.rb
index 9b39d386674..6d2677175e6 100644
--- a/lib/gitlab/template/finders/global_template_finder.rb
+++ b/lib/gitlab/template/finders/global_template_finder.rb
@@ -5,9 +5,10 @@ module Gitlab
module Template
module Finders
class GlobalTemplateFinder < BaseTemplateFinder
- def initialize(base_dir, extension, categories = {}, excluded_patterns: [])
+ def initialize(base_dir, extension, categories = {}, include_categories_for_file = {}, excluded_patterns: [])
@categories = categories
@extension = extension
+ @include_categories_for_file = include_categories_for_file
@excluded_patterns = excluded_patterns
super(base_dir)
@@ -47,7 +48,9 @@ module Gitlab
end
def select_directory(file_name)
- @categories.keys.find do |category|
+ categories = @categories
+ categories.merge!(@include_categories_for_file[file_name]) if @include_categories_for_file[file_name].present?
+ categories.keys.find do |category|
File.exist?(File.join(category_directory(category), file_name))
end
end
diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb
index c295cc75da5..01158cafc4f 100644
--- a/lib/gitlab/template/gitlab_ci_yml_template.rb
+++ b/lib/gitlab/template/gitlab_ci_yml_template.rb
@@ -25,6 +25,12 @@ module Gitlab
}
end
+ def include_categories_for_file
+ {
+ "SAST#{self.extension}" => { 'Security' => 'Security' }
+ }
+ end
+
def excluded_patterns
strong_memoize(:excluded_patterns) do
BASE_EXCLUDED_PATTERNS + additional_excluded_patterns
@@ -41,7 +47,11 @@ module Gitlab
def finder(project = nil)
Gitlab::Template::Finders::GlobalTemplateFinder.new(
- self.base_dir, self.extension, self.categories, excluded_patterns: self.excluded_patterns
+ self.base_dir,
+ self.extension,
+ self.categories,
+ self.include_categories_for_file,
+ excluded_patterns: self.excluded_patterns
)
end
end