2020-01-31 13:09:11 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class CommitSignature < Grape::Entity
|
2020-04-03 14:10:03 -04:00
|
|
|
expose :signature_type
|
2020-11-08 22:09:03 -05:00
|
|
|
|
2020-04-03 14:10:03 -04:00
|
|
|
expose :signature, merge: true do |commit, options|
|
2020-11-08 22:09:03 -05:00
|
|
|
if commit.signature.is_a?(GpgSignature) || commit.raw_commit_from_rugged?
|
|
|
|
::API::Entities::GpgCommitSignature.represent commit_signature(commit), options
|
2020-04-03 14:10:03 -04:00
|
|
|
elsif commit.signature.is_a?(X509CommitSignature)
|
|
|
|
::API::Entities::X509Signature.represent commit.signature, options
|
|
|
|
end
|
|
|
|
end
|
2020-11-08 22:09:03 -05:00
|
|
|
|
|
|
|
expose :commit_source do |commit, _|
|
|
|
|
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-01-31 13:09:11 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|