2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class Tag < Grape::Entity
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :name, documentation: { type: 'string', example: 'v1.0.0' }
|
|
|
|
expose :message, documentation: { type: 'string', example: 'Release v1.0.0' }
|
|
|
|
expose :target, documentation: { type: 'string', example: '2695effb5807a22ff3d138d593fd856244e155e7' }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
expose :commit, using: Entities::Commit do |repo_tag, options|
|
|
|
|
options[:project].repository.commit(repo_tag.dereferenced_target)
|
|
|
|
end
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
expose :release, using: Entities::TagRelease do |repo_tag, options|
|
|
|
|
options[:project].releases.find_by(tag: repo_tag.name)
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :protected, documentation: { type: 'boolean', example: true } do |repo_tag, options|
|
2020-03-13 15:44:24 +05:30
|
|
|
::ProtectedTag.protected?(options[:project], repo_tag.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|