2015-11-21 16:34:53 -05:00
|
|
|
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)
|
2016-07-06 09:26:59 -04:00
|
|
|
super().merge(release: release)
|
2015-11-21 16:34:53 -05:00
|
|
|
end
|
|
|
|
end
|