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
Jérome Perrin
gitlab-ce
Commits
9c3b24ed
Commit
9c3b24ed
authored
Oct 13, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify tags API
parent
36dafbbb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
49 deletions
+45
-49
lib/api/tags.rb
lib/api/tags.rb
+45
-49
No files found.
lib/api/tags.rb
View file @
9c3b24ed
...
@@ -4,25 +4,24 @@ module API
...
@@ -4,25 +4,24 @@ module API
before
{
authenticate!
}
before
{
authenticate!
}
before
{
authorize!
:download_code
,
user_project
}
before
{
authorize!
:download_code
,
user_project
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
resource
:projects
do
# Get a project repository tags
desc
'Get a project repository tags'
do
#
success
Entities
::
RepoTag
# Parameters:
end
# id (required) - The ID of a project
# Example Request:
# GET /projects/:id/repository/tags
get
":id/repository/tags"
do
get
":id/repository/tags"
do
present
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
,
present
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
,
with:
Entities
::
RepoTag
,
project:
user_project
with:
Entities
::
RepoTag
,
project:
user_project
end
end
# Get a single repository tag
desc
'Get a single repository tag'
do
#
success
Entities
::
RepoTag
# Parameters:
end
# id (required) - The ID of a project
params
do
# tag_name (required) - The name of the tag
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
# Example Request:
end
# GET /projects/:id/repository/tags/:tag_name
get
":id/repository/tags/:tag_name"
,
requirements:
{
tag_name:
/.+/
}
do
get
":id/repository/tags/:tag_name"
,
requirements:
{
tag_name:
/.+/
}
do
tag
=
user_project
.
repository
.
find_tag
(
params
[
:tag_name
])
tag
=
user_project
.
repository
.
find_tag
(
params
[
:tag_name
])
not_found!
(
'Tag'
)
unless
tag
not_found!
(
'Tag'
)
unless
tag
...
@@ -30,20 +29,21 @@ module API
...
@@ -30,20 +29,21 @@ module API
present
tag
,
with:
Entities
::
RepoTag
,
project:
user_project
present
tag
,
with:
Entities
::
RepoTag
,
project:
user_project
end
end
# Create tag
desc
'Create a new repository tag'
do
#
success
Entities
::
RepoTag
# Parameters:
end
# id (required) - The ID of a project
params
do
# tag_name (required) - The name of the tag
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
# ref (required) - Create tag from commit sha or branch
requires
:ref
,
type:
String
,
desc:
'The commit sha or branch name'
# message (optional) - Specifying a message creates an annotated tag.
optional
:message
,
type:
String
,
desc:
'Specifying a message creates an annotated tag'
# Example Request:
optional
:release_description
,
type:
String
,
desc:
'Specifying release notes stored in the GitLab database'
# POST /projects/:id/repository/tags
end
post
':id/repository/tags'
do
post
':id/repository/tags'
do
authorize_push_project
authorize_push_project
message
=
params
[
:message
]
||
nil
create_params
=
declared
(
params
)
result
=
CreateTagService
.
new
(
user_project
,
current_user
).
result
=
CreateTagService
.
new
(
user_project
,
current_user
).
execute
(
params
[
:tag_name
],
params
[
:ref
],
message
,
params
[
:release_description
])
execute
(
create_params
[
:tag_name
],
create_params
[
:ref
],
create_params
[
:message
],
create_
params
[
:release_description
])
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
present
result
[
:tag
],
present
result
[
:tag
],
...
@@ -54,15 +54,13 @@ module API
...
@@ -54,15 +54,13 @@ module API
end
end
end
end
# Delete tag
desc
'Delete a repository tag'
#
params
do
# Parameters:
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
# id (required) - The ID of a project
end
# tag_name (required) - The name of the tag
# Example Request:
# DELETE /projects/:id/repository/tags/:tag
delete
":id/repository/tags/:tag_name"
,
requirements:
{
tag_name:
/.+/
}
do
delete
":id/repository/tags/:tag_name"
,
requirements:
{
tag_name:
/.+/
}
do
authorize_push_project
authorize_push_project
result
=
DeleteTagService
.
new
(
user_project
,
current_user
).
result
=
DeleteTagService
.
new
(
user_project
,
current_user
).
execute
(
params
[
:tag_name
])
execute
(
params
[
:tag_name
])
...
@@ -75,17 +73,16 @@ module API
...
@@ -75,17 +73,16 @@ module API
end
end
end
end
# Add release notes to tag
desc
'Add a release note to a tag'
do
#
success
Entities
::
Release
# Parameters:
end
# id (required) - The ID of a project
params
do
# tag_name (required) - The name of the tag
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
# description (required) - Release notes with markdown support
requires
:description
,
type:
String
,
desc:
'Release notes with markdown support'
# Example Request:
end
# POST /projects/:id/repository/tags/:tag_name/release
post
':id/repository/tags/:tag_name/release'
,
requirements:
{
tag_name:
/.+/
}
do
post
':id/repository/tags/:tag_name/release'
,
requirements:
{
tag_name:
/.+/
}
do
authorize_push_project
authorize_push_project
required_attributes!
[
:description
]
result
=
CreateReleaseService
.
new
(
user_project
,
current_user
).
result
=
CreateReleaseService
.
new
(
user_project
,
current_user
).
execute
(
params
[
:tag_name
],
params
[
:description
])
execute
(
params
[
:tag_name
],
params
[
:description
])
...
@@ -96,17 +93,16 @@ module API
...
@@ -96,17 +93,16 @@ module API
end
end
end
end
# Updates a release notes of a tag
desc
"Update a tag's release note"
do
#
success
Entities
::
Release
# Parameters:
end
# id (required) - The ID of a project
params
do
# tag_name (required) - The name of the tag
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
# description (required) - Release notes with markdown support
requires
:description
,
type:
String
,
desc:
'Release notes with markdown support'
# Example Request:
end
# PUT /projects/:id/repository/tags/:tag_name/release
put
':id/repository/tags/:tag_name/release'
,
requirements:
{
tag_name:
/.+/
}
do
put
':id/repository/tags/:tag_name/release'
,
requirements:
{
tag_name:
/.+/
}
do
authorize_push_project
authorize_push_project
required_attributes!
[
:description
]
result
=
UpdateReleaseService
.
new
(
user_project
,
current_user
).
result
=
UpdateReleaseService
.
new
(
user_project
,
current_user
).
execute
(
params
[
:tag_name
],
params
[
:description
])
execute
(
params
[
:tag_name
],
params
[
:description
])
...
...
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