summaryrefslogtreecommitdiff
path: root/app/services/update_release_service.rb
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-12-13 12:08:53 +0100
committerShinya Maeda <shinya@gitlab.com>2018-12-31 12:05:56 +0900
commit1ea2d9faa518f6b769b05a71a1f93b4ea0226bc1 (patch)
tree291cd8d7a6c6113e75219dc873e24fb414df119d /app/services/update_release_service.rb
parentc07bf1abf2a5c3751e575ee5926e9a052fa0b341 (diff)
downloadgitlab-ce-1ea2d9faa518f6b769b05a71a1f93b4ea0226bc1.tar.gz
Add releases API
This commit introduces Releases API under /api/v4/projects/:id/releases * We are introducing release policies at project level. * We are deprecating releases changes from tags, both api and web interface. * Tags::CreateService no longer create a release This feature is controlled by :releases_page feature flag
Diffstat (limited to 'app/services/update_release_service.rb')
-rw-r--r--app/services/update_release_service.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/app/services/update_release_service.rb b/app/services/update_release_service.rb
index e2228ca026c..b51e72c7bfc 100644
--- a/app/services/update_release_service.rb
+++ b/app/services/update_release_service.rb
@@ -1,18 +1,28 @@
# frozen_string_literal: true
class UpdateReleaseService < BaseService
+ attr_accessor :tag_name
+
+ def initialize(project, user, tag_name, params)
+ super(project, user, params)
+
+ @tag_name = tag_name
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
- def execute(tag_name, release_description)
+ def execute
repository = project.repository
- existing_tag = repository.find_tag(tag_name)
+ existing_tag = repository.find_tag(@tag_name)
if existing_tag
- release = project.releases.find_by(tag: tag_name)
+ release = project.releases.find_by(tag: @tag_name)
if release
- release.update(description: release_description)
-
- success(release)
+ if release.update(params)
+ success(release)
+ else
+ error(release.errors.messages || '400 Bad request', 400)
+ end
else
error('Release does not exist', 404)
end