Class: Tags::DestroyService
- Inherits:
-
BaseService
- Object
- BaseService
- Tags::DestroyService
- Defined in:
- app/services/tags/destroy_service.rb
Constant Summary
Constants inherited from BaseService
BaseService::UnauthorizedError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #error(message, return_code = 400) ⇒ Object
- #execute(tag_name, skip_find: false) ⇒ Object
- #success(message) ⇒ Object
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#error(message, return_code = 400) ⇒ Object
32 33 34 |
# File 'app/services/tags/destroy_service.rb', line 32 def error(, return_code = 400) super().merge(return_code: return_code) end |
#execute(tag_name, skip_find: false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/tags/destroy_service.rb', line 5 def execute(tag_name, skip_find: false) repository = project.repository # If we've found the tag upstream we don't need to refind it so we can # pass skip_find: true unless skip_find tag = repository.find_tag(tag_name) return error('No such tag', 404) unless tag return error("You don't have access to delete the tag") unless allowed_to_delete?(tag) end repository.rm_tag(current_user, tag_name) # When a tag in a repository is destroyed, release assets will be # destroyed too. destroy_releases(tag_name) unlock_artifacts(tag_name) success('Tag was removed') rescue Gitlab::Git::PreReceiveError => ex error(ex.) rescue Gitlab::Git::CommandError failed_to_remove_tag_error end |
#success(message) ⇒ Object
36 37 38 |
# File 'app/services/tags/destroy_service.rb', line 36 def success() super().merge(message: ) end |