diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /lib/api/entities/basic_project_details.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'lib/api/entities/basic_project_details.rb')
-rw-r--r-- | lib/api/entities/basic_project_details.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/api/entities/basic_project_details.rb b/lib/api/entities/basic_project_details.rb index 2585b2d0b6d..f89e5adca6d 100644 --- a/lib/api/entities/basic_project_details.rb +++ b/lib/api/entities/basic_project_details.rb @@ -15,7 +15,10 @@ module API expose :ssh_url_to_repo, documentation: { type: 'string', example: 'git@gitlab.example.com:gitlab/gitlab.git' } expose :http_url_to_repo, documentation: { type: 'string', example: 'https://gitlab.example.com/gitlab/gitlab.git' } expose :web_url, documentation: { type: 'string', example: 'https://gitlab.example.com/gitlab/gitlab' } - expose :readme_url, documentation: { type: 'string', example: 'https://gitlab.example.com/gitlab/gitlab/blob/master/README.md' } + with_options if: ->(_, _) { user_has_access_to_project_repository? } do + expose :readme_url, documentation: { type: 'string', example: 'https://gitlab.example.com/gitlab/gitlab/blob/master/README.md' } + expose :forks_count, documentation: { type: 'integer', example: 1 } + end expose :license_url, if: :license, documentation: { type: 'string', example: 'https://gitlab.example.com/gitlab/gitlab/blob/master/LICENCE' } do |project| license = project.repository.license_blob @@ -33,7 +36,6 @@ module API project.avatar_url(only_path: false) end - expose :forks_count, documentation: { type: 'integer', example: 1 } expose :star_count, documentation: { type: 'integer', example: 1 } expose :last_activity_at, documentation: { type: 'dateTime', example: '2013-09-30T13:46:02Z' } expose :namespace, using: 'API::Entities::NamespaceBasic' @@ -74,6 +76,10 @@ module API project.topics.pluck(:name).sort # rubocop:disable CodeReuse/ActiveRecord end end + + def user_has_access_to_project_repository? + Ability.allowed?(options[:current_user], :read_code, project) + end end end end |