summaryrefslogtreecommitdiff
path: root/lib/api/entities/tag.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities/tag.rb')
-rw-r--r--lib/api/entities/tag.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/api/entities/tag.rb b/lib/api/entities/tag.rb
index 713bae64d5c..5047258dd97 100644
--- a/lib/api/entities/tag.rb
+++ b/lib/api/entities/tag.rb
@@ -3,6 +3,8 @@
module API
module Entities
class Tag < Grape::Entity
+ include RequestAwareEntity
+
expose :name, documentation: { type: 'string', example: 'v1.0.0' }
expose :message, documentation: { type: 'string', example: 'Release v1.0.0' }
expose :target, documentation: { type: 'string', example: '2695effb5807a22ff3d138d593fd856244e155e7' }
@@ -12,7 +14,7 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
- expose :release, using: Entities::TagRelease do |repo_tag, options|
+ expose :release, using: Entities::TagRelease, if: ->(*) { can_read_release? } do |repo_tag, options|
options[:project].releases.find_by(tag: repo_tag.name)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -20,6 +22,10 @@ module API
expose :protected, documentation: { type: 'boolean', example: true } do |repo_tag, options|
::ProtectedTag.protected?(options[:project], repo_tag.name)
end
+
+ def can_read_release?
+ can?(options[:current_user], :read_release, options[:project])
+ end
end
end
end