summaryrefslogtreecommitdiff
path: root/lib/api/releases.rb
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-12-21 17:40:14 +0100
committerShinya Maeda <shinya@gitlab.com>2018-12-31 14:34:15 +0900
commit6a2decf5454922441606fce1560389acbbd9eff1 (patch)
tree1434716df04a5a8623943c85bd5b074b53320cee /lib/api/releases.rb
parenta7aaad96f3cca5be2886bf3e18c81a7b06e5129f (diff)
downloadgitlab-ce-6a2decf5454922441606fce1560389acbbd9eff1.tar.gz
Refactor Release services
CreateReleaseService and UpdateReleaseService now takes all the release attributes as constructor parameters. This will simplify attribute expansion
Diffstat (limited to 'lib/api/releases.rb')
-rw-r--r--lib/api/releases.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index 1e6867ee154..2d4a6a28998 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -46,15 +46,19 @@ module API
end
params do
requires :name, type: String, desc: 'The name of the release'
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :description, type: String, desc: 'The release notes'
optional :ref, type: String, desc: 'The commit sha or branch name'
end
post ':id/releases' do
authorize_create_release!
- result = ::CreateReleaseService.new(user_project, current_user)
- .execute(params[:tag_name], params[:description], params[:name], params[:ref])
+ attributes = declared(params)
+ ref = attributes.delete(:ref)
+ attributes.delete(:id)
+
+ result = ::CreateReleaseService.new(user_project, current_user, attributes)
+ .execute(ref)
if result[:status] == :success
present result[:release], with: Entities::Release
@@ -68,7 +72,7 @@ module API
success Entities::Release
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :name, type: String, desc: 'The name of the release'
requires :description, type: String, desc: 'Release notes with markdown support'
end
@@ -76,8 +80,8 @@ module API
authorize_update_release!
attributes = declared(params)
- tag = attributes.delete(:tag_name)
- result = UpdateReleaseService.new(user_project, current_user, tag, attributes).execute
+ attributes.delete(:id)
+ result = UpdateReleaseService.new(user_project, current_user, attributes).execute
if result[:status] == :success
present result[:release], with: Entities::Release