mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 21:56:19 +10:00
Merge branch 'api-delete-tag' into 'master'
Delete tag via API ### What does this MR do? Implements deleting a tag via the API. ### Are there points in the code the reviewer needs to double check? On success, it returns the name of the deleted tag. This is similar to the [delete branch API](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/api/branches.rb#L111). ### What are the relevant issue numbers / Feature requests? * This MR closes #1575 * Closes http://feedback.gitlab.com/forums/176466-general/suggestions/6599203-delete-tags-through-the-api @stanhu Could you do a review? See merge request !1862
This commit is contained in:
@@ -27,6 +27,7 @@ v 8.4.0 (unreleased)
|
||||
- Properly set task-list class on single item task lists
|
||||
- Add file finder feature in tree view (Kyungchul Shin)
|
||||
- Ajax filter by message for commits page
|
||||
- API: Add support for deleting a tag via the API (Robert Schilling)
|
||||
|
||||
v 8.3.3 (unreleased)
|
||||
- Get "Merge when build succeeds" to work when commits were pushed to MR target branch while builds were running
|
||||
|
||||
@@ -83,6 +83,26 @@ it will contain the annotation.
|
||||
It returns 200 if the operation succeed. In case of an error,
|
||||
405 with an explaining error message is returned.
|
||||
|
||||
## Delete a tag
|
||||
|
||||
Deletes a tag of a repository with given name. On success, this API method
|
||||
returns 200 with the name of the deleted tag. If the tag does not exist, the
|
||||
API returns 404.
|
||||
|
||||
```
|
||||
DELETE /projects/:id/repository/tags/:tag_name
|
||||
```
|
||||
|
||||
Parameters:
|
||||
|
||||
- `id` (required) - The ID of a project
|
||||
- `tag_name` (required) - The name of a tag
|
||||
|
||||
```json
|
||||
{
|
||||
"tag_name": "v4.3.0"
|
||||
}
|
||||
```
|
||||
|
||||
## Create a new release
|
||||
|
||||
|
||||
@@ -40,6 +40,27 @@ module API
|
||||
end
|
||||
end
|
||||
|
||||
# Delete tag
|
||||
#
|
||||
# Parameters:
|
||||
# id (required) - The ID of a project
|
||||
# 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
|
||||
authorize_push_project
|
||||
result = DeleteTagService.new(user_project, current_user).
|
||||
execute(params[:tag_name])
|
||||
|
||||
if result[:status] == :success
|
||||
{
|
||||
tag_name: params[:tag_name]
|
||||
}
|
||||
else
|
||||
render_api_error!(result[:message], result[:return_code])
|
||||
end
|
||||
end
|
||||
|
||||
# Add release notes to tag
|
||||
#
|
||||
# Parameters:
|
||||
|
||||
@@ -65,6 +65,27 @@ describe API::API, api: true do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /projects/:id/repository/tags/:tag_name' do
|
||||
let(:tag_name) { project.repository.tag_names.sort.reverse.first }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(Repository).to receive(:rm_tag).and_return(true)
|
||||
end
|
||||
|
||||
context 'delete tag' do
|
||||
it 'should delete an existing tag' do
|
||||
delete api("/projects/#{project.id}/repository/tags/#{tag_name}", user)
|
||||
expect(response.status).to eq(200)
|
||||
expect(json_response['tag_name']).to eq(tag_name)
|
||||
end
|
||||
|
||||
it 'should raise 404 if the tag does not exist' do
|
||||
delete api("/projects/#{project.id}/repository/tags/foobar", user)
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'annotated tag' do
|
||||
it 'should create a new annotated tag' do
|
||||
# Identity must be set in .gitconfig to create annotated tag.
|
||||
|
||||
Reference in New Issue
Block a user