Commit 6f555990 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'rc/fix-tags-api' into 'master'

Fix the /projects/:id/repository/tags endpoint to handle dots in the tag name…

See merge request !13368
parents feb8974c 10fe62ec
--- ---
title: Fix the /projects/:id/repository/branches endpoint to handle dots in the branch title: Fix the /projects/:id/repository/branches endpoint to handle dots in the branch
name when the project full patch contains a `/` name when the project full path contains a `/`
merge_request: 13115 merge_request: 13115
author: author:
---
title: Fix the /projects/:id/repository/tags endpoint to handle dots in the tag name
when the project full path contains a `/`
merge_request: 13368
author:
...@@ -18,17 +18,20 @@ Parameters: ...@@ -18,17 +18,20 @@ Parameters:
[ [
{ {
"commit": { "commit": {
"id": "2695effb5807a22ff3d138d593fd856244e155e7",
"short_id": "2695effb",
"title": "Initial commit",
"created_at": "2017-07-26T11:08:53.000+02:00",
"parent_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
],
"message": "Initial commit",
"author_name": "John Smith", "author_name": "John Smith",
"author_email": "john@example.com", "author_email": "john@example.com",
"authored_date": "2012-05-28T04:42:42-07:00", "authored_date": "2012-05-28T04:42:42-07:00",
"committed_date": "2012-05-28T04:42:42-07:00",
"committer_name": "Jack Smith", "committer_name": "Jack Smith",
"committer_email": "jack@example.com", "committer_email": "jack@example.com",
"id": "2695effb5807a22ff3d138d593fd856244e155e7", "committed_date": "2012-05-28T04:42:42-07:00"
"message": "Initial commit",
"parent_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
]
}, },
"release": { "release": {
"tag_name": "1.0.0", "tag_name": "1.0.0",
...@@ -68,16 +71,19 @@ Example Response: ...@@ -68,16 +71,19 @@ Example Response:
"message": null, "message": null,
"commit": { "commit": {
"id": "60a8ff033665e1207714d6670fcd7b65304ec02f", "id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
"message": "v5.0.0\n", "short_id": "60a8ff03",
"title": "Initial commit",
"created_at": "2017-07-26T11:08:53.000+02:00",
"parent_ids": [ "parent_ids": [
"f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b" "f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b"
], ],
"authored_date": "2015-02-01T21:56:31.000+01:00", "message": "v5.0.0\n",
"author_name": "Arthur Verschaeve", "author_name": "Arthur Verschaeve",
"author_email": "contact@arthurverschaeve.be", "author_email": "contact@arthurverschaeve.be",
"committed_date": "2015-02-01T21:56:31.000+01:00", "authored_date": "2015-02-01T21:56:31.000+01:00",
"committer_name": "Arthur Verschaeve", "committer_name": "Arthur Verschaeve",
"committer_email": "contact@arthurverschaeve.be" "committer_email": "contact@arthurverschaeve.be",
"committed_date": "2015-02-01T21:56:31.000+01:00"
}, },
"release": null "release": null
} }
...@@ -102,17 +108,20 @@ Parameters: ...@@ -102,17 +108,20 @@ Parameters:
```json ```json
{ {
"commit": { "commit": {
"id": "2695effb5807a22ff3d138d593fd856244e155e7",
"short_id": "2695effb",
"title": "Initial commit",
"created_at": "2017-07-26T11:08:53.000+02:00",
"parent_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
],
"message": "Initial commit",
"author_name": "John Smith", "author_name": "John Smith",
"author_email": "john@example.com", "author_email": "john@example.com",
"authored_date": "2012-05-28T04:42:42-07:00", "authored_date": "2012-05-28T04:42:42-07:00",
"committed_date": "2012-05-28T04:42:42-07:00",
"committer_name": "Jack Smith", "committer_name": "Jack Smith",
"committer_email": "jack@example.com", "committer_email": "jack@example.com",
"id": "2695effb5807a22ff3d138d593fd856244e155e7", "committed_date": "2012-05-28T04:42:42-07:00"
"message": "Initial commit",
"parent_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
]
}, },
"release": { "release": {
"tag_name": "1.0.0", "tag_name": "1.0.0",
......
...@@ -699,7 +699,7 @@ module API ...@@ -699,7 +699,7 @@ module API
class RepoTag < Grape::Entity class RepoTag < Grape::Entity
expose :name, :message expose :name, :message
expose :commit do |repo_tag, options| expose :commit, using: Entities::RepoCommit do |repo_tag, options|
options[:project].repository.commit(repo_tag.dereferenced_target) options[:project].repository.commit(repo_tag.dereferenced_target)
end end
......
...@@ -2,19 +2,21 @@ module API ...@@ -2,19 +2,21 @@ module API
class Tags < Grape::API class Tags < Grape::API
include PaginationParams include PaginationParams
TAG_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
before { authorize! :download_code, user_project } before { authorize! :download_code, user_project }
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: { id: %r{[^/]+} } do resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
desc 'Get a project repository tags' do desc 'Get a project repository tags' do
success Entities::RepoTag success Entities::RepoTag
end end
params do params do
use :pagination use :pagination
end end
get ":id/repository/tags" do get ':id/repository/tags' do
tags = ::Kaminari.paginate_array(user_project.repository.tags.sort_by(&:name).reverse) tags = ::Kaminari.paginate_array(user_project.repository.tags.sort_by(&:name).reverse)
present paginate(tags), with: Entities::RepoTag, project: user_project present paginate(tags), with: Entities::RepoTag, project: user_project
end end
...@@ -25,7 +27,7 @@ module API ...@@ -25,7 +27,7 @@ module API
params do params do
requires :tag_name, type: String, desc: 'The name of the tag' requires :tag_name, type: String, desc: 'The name of the tag'
end end
get ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do get ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS 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
...@@ -60,7 +62,7 @@ module API ...@@ -60,7 +62,7 @@ module API
params do params do
requires :tag_name, type: String, desc: 'The name of the tag' requires :tag_name, type: String, desc: 'The name of the tag'
end end
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_push_project authorize_push_project
result = ::Tags::DestroyService.new(user_project, current_user) result = ::Tags::DestroyService.new(user_project, current_user)
...@@ -78,7 +80,7 @@ module API ...@@ -78,7 +80,7 @@ module API
requires :tag_name, type: String, desc: 'The name of the tag' requires :tag_name, type: String, desc: 'The name of the tag'
requires :description, type: String, desc: 'Release notes with markdown support' requires :description, type: String, desc: 'Release notes with markdown support'
end end
post ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_push_project authorize_push_project
result = CreateReleaseService.new(user_project, current_user) result = CreateReleaseService.new(user_project, current_user)
...@@ -98,7 +100,7 @@ module API ...@@ -98,7 +100,7 @@ module API
requires :tag_name, type: String, desc: 'The name of the tag' requires :tag_name, type: String, desc: 'The name of the tag'
requires :description, type: String, desc: 'Release notes with markdown support' requires :description, type: String, desc: 'Release notes with markdown support'
end end
put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_push_project authorize_push_project
result = UpdateReleaseService.new(user_project, current_user) result = UpdateReleaseService.new(user_project, current_user)
......
{
"type": "object",
"required" : [
"tag_name",
"description"
],
"properties" : {
"tag_name": { "type": ["string", "null"] },
"description": { "type": "string" }
},
"additionalProperties": false
}
{
"type": "object",
"required" : [
"name",
"message",
"commit",
"release"
],
"properties" : {
"name": { "type": "string" },
"message": { "type": ["string", "null"] },
"commit": { "$ref": "commit/basic.json" },
"release": {
"oneOf": [
{ "type": "null" },
{ "$ref": "release.json" }
]
}
},
"additionalProperties": false
}
{
"type": "array",
"items": { "$ref": "tag.json" }
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment