Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 21:28:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 21:28:24 +0300
commit47414496d427785d86832bcaca617233f904a2e0 (patch)
tree55c0e9671c5f513654fabdfc6dea1982528a5f9e /lib/api/entities
parent6b75388b67c35271bc18f2dbd41a72accd927808 (diff)
Add latest changes from gitlab-org/security/gitlab@15-9-stable-ee
Diffstat (limited to 'lib/api/entities')
-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