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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
04a3d27e
Commit
04a3d27e
authored
Nov 21, 2015
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow editing a release in API via PUT method
parent
3ea05c5b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
1 deletion
+112
-1
app/services/create_release_service.rb
app/services/create_release_service.rb
+1
-1
app/services/update_release_service.rb
app/services/update_release_service.rb
+29
-0
doc/api/tags.md
doc/api/tags.md
+23
-0
lib/api/tags.rb
lib/api/tags.rb
+21
-0
spec/requests/api/tags_spec.rb
spec/requests/api/tags_spec.rb
+38
-0
No files found.
app/services/create_release_service.rb
View file @
04a3d27e
...
...
@@ -10,7 +10,7 @@ class CreateReleaseService < BaseService
if
existing_tag
release
=
project
.
releases
.
find_by
(
tag:
tag_name
)
if
(
release
)
if
release
error
(
'Release already exists'
,
409
)
else
release
=
project
.
releases
.
new
({
tag:
tag_name
,
description:
release_description
})
...
...
app/services/update_release_service.rb
0 → 100644
View file @
04a3d27e
require_relative
'base_service'
class
UpdateReleaseService
<
BaseService
def
execute
(
tag_name
,
release_description
)
repository
=
project
.
repository
existing_tag
=
repository
.
find_tag
(
tag_name
)
if
existing_tag
release
=
project
.
releases
.
find_by
(
tag:
tag_name
)
if
release
release
.
update_attributes
(
description:
release_description
)
success
(
release
)
else
error
(
'Release does not exist'
,
404
)
end
else
error
(
'Tag does not exist'
,
404
)
end
end
def
success
(
release
)
out
=
super
()
out
[
:release
]
=
release
out
end
end
doc/api/tags.md
View file @
04a3d27e
...
...
@@ -106,3 +106,26 @@ Parameters:
"description"
:
"Amazing release. Wow"
}
```
## Update a release
Updates the release notes of a given release. It returns 200 if the release is
successfully updated. If the tag or the release does not exist, it returns 404
with a proper error message.
```
PUT /projects/:id/repository/tags/:tag_name/release
```
Parameters:
-
`id`
(required) - The ID of a project
-
`tag_name`
(required) - The name of a tag
-
`description`
(required) - Release notes with markdown support
```
json
{
"tag_name"
:
"1.0.0"
,
"description"
:
"Amazing release. Wow"
}
```
\ No newline at end of file
lib/api/tags.rb
View file @
04a3d27e
...
...
@@ -60,6 +60,27 @@ module API
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
# Updates a release notes of a tag
#
# Parameters:
# id (required) - The ID of a project
# tag_name (required) - The name of the tag
# description (required) - Release notes with markdown support
# Example Request:
# 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
]
result
=
UpdateReleaseService
.
new
(
user_project
,
current_user
).
execute
(
params
[
:tag_name
],
params
[
:description
])
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/tags_spec.rb
View file @
04a3d27e
...
...
@@ -155,4 +155,42 @@ describe API::API, api: true do
end
end
end
describe
'PUT id/repository/tags/:tag_name/release'
do
let
(
:tag_name
)
{
project
.
repository
.
tag_names
.
first
}
let
(
:description
)
{
'Awesome release!'
}
let
(
:new_description
)
{
'The best release!'
}
context
'on tag with existing release'
do
before
do
release
=
project
.
releases
.
find_or_initialize_by
(
tag:
tag_name
)
release
.
update_attributes
(
description:
description
)
end
it
'should update the release description'
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/tags/
#{
tag_name
}
/release"
,
user
),
description:
new_description
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'tag_name'
]).
to
eq
(
tag_name
)
expect
(
json_response
[
'description'
]).
to
eq
(
new_description
)
end
end
it
'should return 404 if the tag does not exist'
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/tags/foobar/release"
,
user
),
description:
new_description
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Tag does not exist'
)
end
it
'should return 404 if the release does not exist'
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/tags/
#{
tag_name
}
/release"
,
user
),
description:
new_description
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Release does not exist'
)
end
end
end
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