Commit 2cba93a0 authored by Robert Schilling's avatar Robert Schilling

Make tag API consistent for release feature

parent 4427e80f
......@@ -29,7 +29,7 @@ Parameters:
]
},
"release": {
"tag": "1.0.0",
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
},
"name": "v1.0.0",
......@@ -70,7 +70,7 @@ Parameters:
]
},
"release": {
"tag": "1.0.0",
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
},
"name": "v1.0.0",
......@@ -89,18 +89,18 @@ It returns 200 if the operation succeed. In case of an error,
Add release notes to the existing git tag
```
PUT /projects/:id/repository/:tag/release
PUT /projects/:id/repository/tags/:tag_name/release
```
Parameters:
- `id` (required) - The ID of a project
- `tag` (required) - The name of a tag
- `tag_name` (required) - The name of a tag
- `description` (required) - Release notes with markdown support
```json
{
"tag": "1.0.0",
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
```
......@@ -322,7 +322,8 @@ module API
end
class Release < Grape::Entity
expose :tag, :description
expose :tag, as: :tag_name
expose :description
end
class RepoTag < Grape::Entity
......
......@@ -44,14 +44,14 @@ module API
#
# Parameters:
# id (required) - The ID of a project
# tag (required) - The name of the tag
# tag_name (required) - The name of the tag
# description (required) - Release notes with markdown support
# Example Request:
# PUT /projects/:id/repository/tags
put ':id/repository/:tag/release', requirements: { tag: /.*/ } do
# PUT /projects/:id/repository/tags/:tag_name/release
put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.*/ } do
authorize_push_project
required_attributes! [:description]
release = user_project.releases.find_or_initialize_by(tag: params[:tag])
release = user_project.releases.find_or_initialize_by(tag: params[:tag_name])
release.update_attributes(description: params[:description])
present release, with: Entities::Release
......
......@@ -119,16 +119,16 @@ describe API::API, api: true do
end
end
describe 'PUT /projects/:id/repository/:tag/release' do
describe 'PUT /projects/:id/repository/tags/:tag_name/release' do
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
it 'should create description for existing git tag' do
put api("/projects/#{project.id}/repository/#{tag_name}/release", user),
put api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: description
expect(response.status).to eq(200)
expect(json_response['tag']).to eq(tag_name)
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(description)
end
end
......
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