diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-19 03:09:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-19 03:09:00 +0300 |
commit | f7a5fe52f013009251300e9d33caf21199cdb066 (patch) | |
tree | 92e424e8faabcff570debf57e7dd926b0b849696 /app/presenters | |
parent | 7d46e0437fb6e41b1a597ed159a4c1f2b0beca7b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/packages/composer/packages_presenter.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/app/presenters/packages/composer/packages_presenter.rb b/app/presenters/packages/composer/packages_presenter.rb index 8e3f482126d..2eb9b8910a3 100644 --- a/app/presenters/packages/composer/packages_presenter.rb +++ b/app/presenters/packages/composer/packages_presenter.rb @@ -5,25 +5,35 @@ module Packages class PackagesPresenter include API::Helpers::RelatedResourcesHelpers - def initialize(group, packages) + def initialize(group, packages, is_v2 = false) @group = group @packages = packages + @is_v2 = is_v2 end def root - v1_path = expose_path(api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true)) v2_path = expose_path(api_v4_group___packages_composer_p2_package_name_path({ id: @group.id, package_name: '%package%', format: '.json' }, true)) - { + index = { 'packages' => [], + 'metadata-url' => v2_path + } + + # if the client is composer v2 then we don't want to + # include the provider_sha since it is computationally expensive + # to compute. + return index if @is_v2 + + v1_path = expose_path(api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true)) + + index.merge!( 'provider-includes' => { 'p/%hash%.json' => { 'sha256' => provider_sha } }, - 'providers-url' => v1_path, - 'metadata-url' => v2_path - } + 'providers-url' => v1_path + ) end def provider |