summaryrefslogtreecommitdiff
path: root/lib/gitlab/template
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /lib/gitlab/template
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'lib/gitlab/template')
-rw-r--r--lib/gitlab/template/base_template.rb7
-rw-r--r--lib/gitlab/template/dockerfile_template.rb5
-rw-r--r--lib/gitlab/template/gitlab_ci_syntax_yml_template.rb29
-rw-r--r--lib/gitlab/template/gitlab_ci_yml_template.rb5
-rw-r--r--lib/gitlab/template/metrics_dashboard_template.rb5
5 files changed, 41 insertions, 10 deletions
diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb
index e84937ec4ad..b659bff52ad 100644
--- a/lib/gitlab/template/base_template.rb
+++ b/lib/gitlab/template/base_template.rb
@@ -23,7 +23,12 @@ module Gitlab
end
def content
- @finder.read(@path)
+ blob = @finder.read(@path)
+ [description, blob].compact.join("\n")
+ end
+
+ def description
+ # override with a comment to be placed at the top of the blob.
end
# Present for compatibility with license templates, which can replace text
diff --git a/lib/gitlab/template/dockerfile_template.rb b/lib/gitlab/template/dockerfile_template.rb
index 3b516bb862a..09643cfb619 100644
--- a/lib/gitlab/template/dockerfile_template.rb
+++ b/lib/gitlab/template/dockerfile_template.rb
@@ -3,9 +3,8 @@
module Gitlab
module Template
class DockerfileTemplate < BaseTemplate
- def content
- explanation = "# This file is a template, and might need editing before it works on your project."
- [explanation, super].join("\n")
+ def description
+ "# This file is a template, and might need editing before it works on your project."
end
class << self
diff --git a/lib/gitlab/template/gitlab_ci_syntax_yml_template.rb b/lib/gitlab/template/gitlab_ci_syntax_yml_template.rb
new file mode 100644
index 00000000000..3bf3a28d3c5
--- /dev/null
+++ b/lib/gitlab/template/gitlab_ci_syntax_yml_template.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Template
+ class GitlabCiSyntaxYmlTemplate < BaseTemplate
+ class << self
+ def extension
+ '.gitlab-ci.yml'
+ end
+
+ def categories
+ {
+ 'General' => ''
+ }
+ end
+
+ def base_dir
+ Rails.root.join('lib/gitlab/ci/syntax_templates')
+ end
+
+ def finder(project = nil)
+ Gitlab::Template::Finders::GlobalTemplateFinder.new(
+ self.base_dir, self.extension, self.categories
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb
index e12af6bf0a4..c295cc75da5 100644
--- a/lib/gitlab/template/gitlab_ci_yml_template.rb
+++ b/lib/gitlab/template/gitlab_ci_yml_template.rb
@@ -5,9 +5,8 @@ module Gitlab
class GitlabCiYmlTemplate < BaseTemplate
BASE_EXCLUDED_PATTERNS = [%r{\.latest\.}].freeze
- def content
- explanation = "# This file is a template, and might need editing before it works on your project."
- [explanation, super].join("\n")
+ def description
+ "# This file is a template, and might need editing before it works on your project."
end
class << self
diff --git a/lib/gitlab/template/metrics_dashboard_template.rb b/lib/gitlab/template/metrics_dashboard_template.rb
index 88fc3007b63..469f97d7cb1 100644
--- a/lib/gitlab/template/metrics_dashboard_template.rb
+++ b/lib/gitlab/template/metrics_dashboard_template.rb
@@ -3,9 +3,8 @@
module Gitlab
module Template
class MetricsDashboardTemplate < BaseTemplate
- def content
- explanation = "# This file is a template, and might need editing before it works on your project."
- [explanation, super].join("\n")
+ def description
+ "# This file is a template, and might need editing before it works on your project."
end
class << self