diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-01 18:28:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-01 18:28:50 +0000 |
commit | 165c4fb3de28c1b03b1d3a5e05b8962b73eea228 (patch) | |
tree | 30f2d692638d8d4e16cc9535a965aae80c5961e6 /lib/api/entities/tag.rb | |
parent | 20c396b4c9f52858b386e06d0b64c9f40a0559a2 (diff) | |
download | gitlab-ce-165c4fb3de28c1b03b1d3a5e05b8962b73eea228.tar.gz |
Add latest changes from gitlab-org/security/gitlab@15-8-stable-ee
Diffstat (limited to 'lib/api/entities/tag.rb')
-rw-r--r-- | lib/api/entities/tag.rb | 8 |
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 |