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

Make tag API consistent for release feature

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