Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
483dc62e
Commit
483dc62e
authored
Jun 16, 2016
by
Z.J. van de Weg
Committed by
Alfredo Sumaran
Jun 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate review
parent
96ae6099
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
17 deletions
+34
-17
app/assets/javascripts/api.js.coffee
app/assets/javascripts/api.js.coffee
+3
-3
app/assets/javascripts/blob/blob_ci_yaml.js.coffee
app/assets/javascripts/blob/blob_ci_yaml.js.coffee
+1
-1
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+2
-2
lib/api/templates.rb
lib/api/templates.rb
+5
-1
lib/gitlab/template/base_template.rb
lib/gitlab/template/base_template.rb
+3
-1
lib/gitlab/template/gitlab_ci_yml.rb
lib/gitlab/template/gitlab_ci_yml.rb
+1
-1
lib/tasks/gitlab/update_templates.rake
lib/tasks/gitlab/update_templates.rake
+10
-8
spec/requests/api/templates_spec.rb
spec/requests/api/templates_spec.rb
+9
-0
No files found.
app/assets/javascripts/api.js.coffee
View file @
483dc62e
...
...
@@ -7,7 +7,7 @@
labelsPath
:
"/api/:version/projects/:id/labels"
licensePath
:
"/api/:version/licenses/:key"
gitignorePath
:
"/api/:version/gitignores/:key"
gitlabC
I
YmlPath
:
"/api/:version/gitlab_ci_ymls/:key"
gitlabC
i
YmlPath
:
"/api/:version/gitlab_ci_ymls/:key"
group
:
(
group_id
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
groupPath
)
...
...
@@ -111,8 +111,8 @@
$
.
get
url
,
(
gitignore
)
->
callback
(
gitignore
)
gitlabC
I
Yml
:
(
key
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
gitlabC
I
YmlPath
).
replace
(
':key'
,
key
)
gitlabC
i
Yml
:
(
key
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
gitlabC
i
YmlPath
).
replace
(
':key'
,
key
)
$
.
get
url
,
(
file
)
->
callback
(
file
)
...
...
app/assets/javascripts/blob/blob_ci_yaml.js.coffee
View file @
483dc62e
...
...
@@ -2,7 +2,7 @@
class
@
BlobCiYamlSelector
extends
TemplateSelector
requestFile
:
(
query
)
->
Api
.
gitlabC
I
Yml
query
.
name
,
@
requestFileSuccess
.
bind
(
@
)
Api
.
gitlabC
i
Yml
query
.
name
,
@
requestFileSuccess
.
bind
(
@
)
class
@
BlobCiYamlSelectors
constructor
:
(
opts
)
->
...
...
app/helpers/blob_helper.rb
View file @
483dc62e
...
...
@@ -194,8 +194,8 @@ module BlobHelper
def
gitlab_ci_ymls
@gitlab_ci_ymls
||=
Gitlab
::
Template
::
GitlabC
I
Yml
.
categories
.
keys
.
map
do
|
k
|
[
k
,
Gitlab
::
Template
::
GitlabC
I
Yml
.
by_category
(
k
).
map
{
|
t
|
{
name:
t
.
name
}
}]
Gitlab
::
Template
::
GitlabC
i
Yml
.
categories
.
keys
.
map
do
|
k
|
[
k
,
Gitlab
::
Template
::
GitlabC
i
Yml
.
by_category
(
k
).
map
{
|
t
|
{
name:
t
.
name
}
}]
end
.
to_h
end
end
lib/api/templates.rb
View file @
483dc62e
...
...
@@ -2,7 +2,7 @@ module API
class
Templates
<
Grape
::
API
TEMPLATE_TYPES
=
{
gitignores:
Gitlab
::
Template
::
Gitignore
,
gitlab_ci_ymls:
Gitlab
::
Template
::
GitlabC
I
Yml
gitlab_ci_ymls:
Gitlab
::
Template
::
GitlabC
i
Yml
}.
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
...
...
lib/gitlab/template/base_template.rb
View file @
483dc62e
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
...
...
lib/gitlab/template/gitlab_ci_yml.rb
View file @
483dc62e
module
Gitlab
module
Template
class
GitlabC
I
Yml
<
BaseTemplate
class
GitlabC
i
Yml
<
BaseTemplate
class
<<
self
def
extension
'.gitlab-ci.yml'
...
...
lib/tasks/gitlab/update_templates.rake
View file @
483dc62e
...
...
@@ -37,14 +37,16 @@ namespace :gitlab do
private
Template
=
Struct
.
new
(
:repo_url
,
:cleanup_regex
)
TEMPLATE_DATA
=
[
Template
.
new
(
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'
)
...
...
spec/requests/api/templates_spec.rb
View file @
483dc62e
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment