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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
dc8a8c7d
Commit
dc8a8c7d
authored
Dec 25, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete method in Release API
Introduce DELETE endpoint in Release API
parent
6a2decf5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
0 deletions
+98
-0
app/services/delete_release_service.rb
app/services/delete_release_service.rb
+41
-0
lib/api/releases.rb
lib/api/releases.rb
+21
-0
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+35
-0
spec/services/delete_release_service_spec.rb
spec/services/delete_release_service_spec.rb
+1
-0
No files found.
app/services/delete_release_service.rb
0 → 100644
View file @
dc8a8c7d
# frozen_string_literal: true
class
DeleteReleaseService
<
BaseService
include
Gitlab
::
Utils
::
StrongMemoize
def
execute
return
error
(
'Tag does not exist'
,
404
)
unless
existing_tag
return
error
(
'Release does not exist'
,
404
)
unless
release
return
error
(
'Access Denied'
,
403
)
unless
allowed?
if
release
.
destory
success
(
release:
release
)
else
error
(
release
.
errors
.
messages
||
'400 Bad request'
,
400
)
end
end
private
def
allowed?
Ability
.
allowed?
(
current_user
,
:admin_release
,
release
)
end
def
release
strong_memoize
(
:release
)
do
project
.
releases
.
find_by_tag
(
@tag_name
)
end
end
def
existing_tag
strong_memoize
(
:existing_tag
)
do
repository
.
find_tag
(
@tag_name
)
end
end
def
repository
strong_memoize
(
:repository
)
do
project
.
repository
end
end
end
lib/api/releases.rb
View file @
dc8a8c7d
...
...
@@ -89,6 +89,27 @@ module API
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
desc
'Delete a release'
do
detail
'This feature was introduced in GitLab 11.7.'
success
Entities
::
Release
end
params
do
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
,
as: :tag
end
delete
':id/releases/:tag_name'
,
requirements:
RELEASE_ENDPOINT_REQUIREMETS
do
authorize_update_release!
attributes
=
declared
(
params
)
attributes
.
delete
(
:id
)
result
=
DeleteReleaseService
.
new
(
user_project
,
current_user
,
attributes
).
execute
if
result
[
:status
]
==
:success
present
result
[
:release
],
with:
Entities
::
Release
else
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
end
end
end
spec/requests/api/releases_spec.rb
0 → 100644
View file @
dc8a8c7d
require
'spec_helper'
describe
API
::
Releases
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_guest
(
u
)
}
}
let
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
path:
'my.project'
)
}
let
(
:tag_name
)
{
project
.
repository
.
find_tag
(
'v1.1.0'
).
name
}
let
(
:project_id
)
{
project
.
id
}
let
(
:current_user
)
{
nil
}
before
do
project
.
add_maintainer
(
user
)
end
describe
'GET /projects/:id/releases'
do
# TODO:
end
describe
'GET /projects/:id/releases/:tag_name'
do
# TODO:
end
describe
'POST /projects/:id/releases'
do
# TODO:
end
describe
'PUT /projects/:id/releases/:tag_name'
do
# TODO:
end
describe
'DELETE /projects/:id/releases/:tag_name'
do
# TODO:
end
end
spec/services/delete_release_service_spec.rb
0 → 100644
View file @
dc8a8c7d
#TODO:
\ No newline at end of file
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