summaryrefslogtreecommitdiff
path: root/lib/api/entities/tag.rb
blob: 2d3569bb9bb7ae6452f29b9943de4a97df3cc72e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module API
  module Entities
    class Tag < Grape::Entity
      expose :name, :message, :target

      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

      expose :protected do |repo_tag, options|
        ::ProtectedTag.protected?(options[:project], repo_tag.name)
      end
    end
  end
end