Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-12-21 19:40:14 +0300
committerShinya Maeda <shinya@gitlab.com>2018-12-31 08:34:15 +0300
commit6a2decf5454922441606fce1560389acbbd9eff1 (patch)
tree1434716df04a5a8623943c85bd5b074b53320cee /lib
parenta7aaad96f3cca5be2886bf3e18c81a7b06e5129f (diff)
Refactor Release services
CreateReleaseService and UpdateReleaseService now takes all the release attributes as constructor parameters. This will simplify attribute expansion
Diffstat (limited to 'lib')
-rw-r--r--lib/api/releases.rb16
-rw-r--r--lib/api/tags.rb16
2 files changed, 20 insertions, 12 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
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
index 50ad184ba99..e1e9a7fbae5 100644
--- a/lib/api/tags.rb
+++ b/lib/api/tags.rb
@@ -60,8 +60,10 @@ module API
if result[:status] == :success
# Release creation with Tags API was deprecated in GitLab 11.7
if params[:release_description].present?
- CreateReleaseService.new(user_project, current_user)
- .execute(params[:tag_name], params[:release_description])
+ CreateReleaseService.new(
+ user_project, current_user,
+ tag: params[:tag_name], description: params[:release_description]
+ ).execute
end
present result[:tag],
@@ -99,14 +101,16 @@ module API
success Entities::TagRelease
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 :description, type: String, desc: 'Release notes with markdown support'
end
post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_create_release!
- result = CreateReleaseService.new(user_project, current_user)
- .execute(params[:tag_name], params[:description])
+ attributes = declared(params)
+ attributes.delete(:id)
+ result = CreateReleaseService.new(user_project, current_user, attributes)
+ .execute
if result[:status] == :success
present result[:release], with: Entities::TagRelease
@@ -129,7 +133,7 @@ module API
result = UpdateReleaseService.new(
user_project,
current_user,
- params[:tag_name],
+ tag: params[:tag_name],
description: params[:description]
).execute