2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class CommitSignature < Grape::Entity
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :signature_type, documentation: { type: 'string', example: 'PGP' }
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expose :signature, merge: true do |commit, options|
|
2022-01-26 12:08:38 +05:30
|
|
|
if commit.signature.is_a?(::CommitSignatures::GpgSignature) || commit.raw_commit_from_rugged?
|
2021-01-29 00:20:46 +05:30
|
|
|
::API::Entities::GpgCommitSignature.represent commit_signature(commit), options
|
2022-01-26 12:08:38 +05:30
|
|
|
elsif commit.signature.is_a?(::CommitSignatures::X509CommitSignature)
|
2020-04-22 19:07:51 +05:30
|
|
|
::API::Entities::X509Signature.represent commit.signature, options
|
|
|
|
end
|
|
|
|
end
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :commit_source, documentation: { type: 'string', example: 'gitaly' } do |commit, _|
|
2021-01-29 00:20:46 +05:30
|
|
|
commit.raw_commit_from_rugged? ? "rugged" : "gitaly"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def commit_signature(commit)
|
|
|
|
if commit.raw_commit_from_rugged?
|
|
|
|
commit.gpg_commit.signature
|
|
|
|
else
|
|
|
|
commit.signature
|
|
|
|
end
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|