1# frozen_string_literal: true 2 3module API 4 module Entities 5 class CommitSignature < Grape::Entity 6 expose :signature_type 7 8 expose :signature, merge: true do |commit, options| 9 if commit.signature.is_a?(::CommitSignatures::GpgSignature) || commit.raw_commit_from_rugged? 10 ::API::Entities::GpgCommitSignature.represent commit_signature(commit), options 11 elsif commit.signature.is_a?(::CommitSignatures::X509CommitSignature) 12 ::API::Entities::X509Signature.represent commit.signature, options 13 end 14 end 15 16 expose :commit_source do |commit, _| 17 commit.raw_commit_from_rugged? ? "rugged" : "gitaly" 18 end 19 20 private 21 22 def commit_signature(commit) 23 if commit.raw_commit_from_rugged? 24 commit.gpg_commit.signature 25 else 26 commit.signature 27 end 28 end 29 end 30 end 31end 32