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:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-06-16 16:33:11 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-06-20 22:48:28 +0300
commit483dc62eaac0e11717b5b103317c4441ec0ff23d (patch)
tree40b5954f0f5f0f181d3fa73ec36cd1492d2e0669
parent96ae6099dd5921ae32139a206d598043520fb506 (diff)
Incorporate review
-rw-r--r--app/assets/javascripts/api.js.coffee6
-rw-r--r--app/assets/javascripts/blob/blob_ci_yaml.js.coffee2
-rw-r--r--app/helpers/blob_helper.rb4
-rw-r--r--lib/api/templates.rb6
-rw-r--r--lib/gitlab/template/base_template.rb4
-rw-r--r--lib/gitlab/template/gitlab_ci_yml.rb2
-rw-r--r--lib/tasks/gitlab/update_templates.rake18
-rw-r--r--spec/requests/api/templates_spec.rb9
8 files changed, 34 insertions, 17 deletions
diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee
index d543e3b7a96..cf46f15a156 100644
--- a/app/assets/javascripts/api.js.coffee
+++ b/app/assets/javascripts/api.js.coffee
@@ -7,7 +7,7 @@
labelsPath: "/api/:version/projects/:id/labels"
licensePath: "/api/:version/licenses/:key"
gitignorePath: "/api/:version/gitignores/:key"
- gitlabCIYmlPath: "/api/:version/gitlab_ci_ymls/:key"
+ gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key"
group: (group_id, callback) ->
url = Api.buildUrl(Api.groupPath)
@@ -111,8 +111,8 @@
$.get url, (gitignore) ->
callback(gitignore)
- gitlabCIYml: (key, callback) ->
- url = Api.buildUrl(Api.gitlabCIYmlPath).replace(':key', key)
+ gitlabCiYml: (key, callback) ->
+ url = Api.buildUrl(Api.gitlabCiYmlPath).replace(':key', key)
$.get url, (file) ->
callback(file)
diff --git a/app/assets/javascripts/blob/blob_ci_yaml.js.coffee b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee
index dc14700d305..d9a03d05529 100644
--- a/app/assets/javascripts/blob/blob_ci_yaml.js.coffee
+++ b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee
@@ -2,7 +2,7 @@
class @BlobCiYamlSelector extends TemplateSelector
requestFile: (query) ->
- Api.gitlabCIYml query.name, @requestFileSuccess.bind(@)
+ Api.gitlabCiYml query.name, @requestFileSuccess.bind(@)
class @BlobCiYamlSelectors
constructor: (opts) ->
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index b30a01614be..16d9d7d2d5a 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -194,8 +194,8 @@ module BlobHelper
def gitlab_ci_ymls
@gitlab_ci_ymls ||=
- Gitlab::Template::GitlabCIYml.categories.keys.map do |k|
- [k, Gitlab::Template::GitlabCIYml.by_category(k).map { |t| { name: t.name } }]
+ Gitlab::Template::GitlabCiYml.categories.keys.map do |k|
+ [k, Gitlab::Template::GitlabCiYml.by_category(k).map { |t| { name: t.name } }]
end.to_h
end
end
diff --git a/lib/api/templates.rb b/lib/api/templates.rb
index 9f5f10a5088..33cbb0c9e1b 100644
--- a/lib/api/templates.rb
+++ b/lib/api/templates.rb
@@ -2,7 +2,7 @@ module API
class Templates < Grape::API
TEMPLATE_TYPES = {
gitignores: Gitlab::Template::Gitignore,
- gitlab_ci_ymls: Gitlab::Template::GitlabCIYml
+ gitlab_ci_ymls: Gitlab::Template::GitlabCiYml
}.freeze
TEMPLATE_TYPES.each do |template, klass|
@@ -29,6 +29,10 @@ module API
new_template = klass.find(params[:name])
not_found!("#{template.to_s.singularize}") unless new_template
+ if new_template.class == Gitlab::Template::GitlabCiYml
+ new_template.content = "# This file is a template, and might need editing before it works on your project.\n" + new_template.content
+ end
+
present new_template, with: Entities::Template
end
end
diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb
index 652a496b57b..4086d8701bf 100644
--- a/lib/gitlab/template/base_template.rb
+++ b/lib/gitlab/template/base_template.rb
@@ -1,6 +1,8 @@
module Gitlab
module Template
class BaseTemplate
+ attr_writer :content
+
def initialize(path)
@path = path
end
@@ -10,7 +12,7 @@ module Gitlab
end
def content
- File.read(@path)
+ @content ||= File.read(@path)
end
def categories
diff --git a/lib/gitlab/template/gitlab_ci_yml.rb b/lib/gitlab/template/gitlab_ci_yml.rb
index da7273b8d70..f1e96d22d64 100644
--- a/lib/gitlab/template/gitlab_ci_yml.rb
+++ b/lib/gitlab/template/gitlab_ci_yml.rb
@@ -1,6 +1,6 @@
module Gitlab
module Template
- class GitlabCIYml < BaseTemplate
+ class GitlabCiYml < BaseTemplate
class << self
def extension
'.gitlab-ci.yml'
diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake
index 14277fe4c4b..2d3c7993445 100644
--- a/lib/tasks/gitlab/update_templates.rake
+++ b/lib/tasks/gitlab/update_templates.rake
@@ -37,14 +37,16 @@ namespace :gitlab do
private
Template = Struct.new(:repo_url, :cleanup_regex)
- TEMPLATE_DATA = [Template.new(
- "https://github.com/github/gitignore.git",
- /(\.{1,2}|LICENSE|Global|\.gitignore)\z/
- ),
- Template.new(
- "https://gitlab.com/gitlab-org/gitlab-ci-yml.git",
- /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/
- )]
+ TEMPLATE_DATA = [
+ Template.new(
+ "https://github.com/github/gitignore.git",
+ /(\.{1,2}|LICENSE|Global|\.gitignore)\z/
+ ),
+ Template.new(
+ "https://gitlab.com/gitlab-org/gitlab-ci-yml.git",
+ /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/
+ )
+ ]
def vendor_directory
Rails.root.join('vendor')
diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb
index 0e9a28b1ff6..a6d5ade3013 100644
--- a/spec/requests/api/templates_spec.rb
+++ b/spec/requests/api/templates_spec.rb
@@ -40,4 +40,13 @@ describe API::Templates, api: true do
end
end
end
+
+ describe 'GET /gitlab_ci_ymls/Ruby' do
+ it 'adds a disclaimer on the top' do
+ get api('/gitlab_ci_ymls/Ruby')
+
+ expect(response.status).to eq(200)
+ expect(json_response['content']).to start_with("# This file is a template,")
+ end
+ end
end