diff options
author | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2023-03-02 14:46:43 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2023-03-02 14:46:43 +0000 |
commit | 623e40c9bbb8b9c8cbca620ad3a663b33c15abcf (patch) | |
tree | 08272c8e5eca9e4f680868d8dcd3794f764d287a /lib/api/entities/tag.rb | |
parent | 6b75388b67c35271bc18f2dbd41a72accd927808 (diff) | |
parent | d5a415f1e66f24f55e70a37f18c6e9e81d2b73ee (diff) | |
download | gitlab-ce-623e40c9bbb8b9c8cbca620ad3a663b33c15abcf.tar.gz |
Merge remote-tracking branch 'dev/15-9-stable' into 15-9-stable
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 |