Commit b9aac409 authored by Alessio Caiazza's avatar Alessio Caiazza Committed by Shinya Maeda

Expose assets in releases API

parent 1ea2d9fa
...@@ -17,4 +17,17 @@ class Release < ActiveRecord::Base ...@@ -17,4 +17,17 @@ class Release < ActiveRecord::Base
git_tag = repository.find_tag(tag) git_tag = repository.find_tag(tag)
repository.commit(git_tag.dereferenced_target) repository.commit(git_tag.dereferenced_target)
end end
def sources_formats
@sources_formats ||= %w(zip tar.gz tar.bz2 tar).freeze
end
# TODO: placeholder for frontend API compatibility
def links
[]
end
def assets_count
links.size + sources_formats.size
end
end end
...@@ -1099,6 +1099,20 @@ module API ...@@ -1099,6 +1099,20 @@ module API
expose :created_at expose :created_at
expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? } expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? }
expose :commit, using: Entities::Commit expose :commit, using: Entities::Commit
expose :assets do
expose :assets_count, as: :count
expose :links
expose :sources do |release, _opts|
archive_path = "#{release.project.path}-#{release.tag.tr('/', '-')}"
release.sources_formats.map do |format|
{
format: format,
url: Gitlab::Routing.url_helpers.project_archive_url(release.project, id: File.join(release.tag, archive_path), format: format)
}
end
end
end
end end
class Tag < Grape::Entity class Tag < Grape::Entity
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment