diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/presenters/packages/composer/packages_presenter.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/presenters/packages/composer/packages_presenter.rb')
-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 |