diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-12 18:10:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-12 18:10:37 +0300 |
commit | 84dd3070dff9e36897345bbfd8dc1bf3470376ae (patch) | |
tree | 022fb1c625685b0dfbbdb0c4cf576df272d52043 /app/presenters | |
parent | bbfd13e575237aaa69a49caf1e23ebd878c2f824 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/packages/composer/packages_presenter.rb | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/app/presenters/packages/composer/packages_presenter.rb b/app/presenters/packages/composer/packages_presenter.rb index cce006cbb1a..ed0e9d3b731 100644 --- a/app/presenters/packages/composer/packages_presenter.rb +++ b/app/presenters/packages/composer/packages_presenter.rb @@ -20,33 +20,17 @@ module Packages end def package_versions(packages = @packages) - { 'packages' => { packages.first.name => package_versions_map(packages) } } + package_versions_index(packages).as_json end private - def package_versions_map(packages) - packages.each_with_object({}) do |package, map| - map[package.version] = package_metadata(package) - end + def package_versions_sha(packages = @packages) + package_versions_index(packages).sha end - def package_metadata(package) - json = package.composer_metadatum.composer_json - - json.merge('dist' => package_dist(package), 'uid' => package.id, 'version' => package.version) - end - - def package_dist(package) - sha = package.composer_metadatum.target_sha - archive_api_path = api_v4_projects_packages_composer_archives_package_name_path({ id: package.project_id, package_name: package.name, format: '.zip' }, true) - - { - 'type' => 'zip', - 'url' => expose_url(archive_api_path) + "?sha=#{sha}", - 'reference' => sha, - 'shasum' => '' - } + def package_versions_index(packages) + ::Gitlab::Composer::VersionIndex.new(packages) end def providers_map @@ -59,10 +43,6 @@ module Packages map end - def package_versions_sha(packages) - Digest::SHA256.hexdigest(package_versions(packages).to_json) - end - def provider_sha Digest::SHA256.hexdigest(provider.to_json) end |