提交 b9aac409 编写于 作者: A Alessio Caiazza 提交者: Shinya Maeda

Expose assets in releases API

上级 1ea2d9fa
......@@ -17,4 +17,17 @@ class Release < ActiveRecord::Base
git_tag = repository.find_tag(tag)
repository.commit(git_tag.dereferenced_target)
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
......@@ -1099,6 +1099,20 @@ module API
expose :created_at
expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? }
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
class Tag < Grape::Entity
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册