Add API endpoint to get a commit's GPG signature
This commit is contained in:
parent
c6016ac8a8
commit
034d1d02b9
2 changed files with 23 additions and 0 deletions
|
@ -323,6 +323,22 @@ module API
|
|||
|
||||
present paginate(commit.merge_requests), with: Entities::MergeRequestBasic
|
||||
end
|
||||
|
||||
desc "Get a commit's GPG signature" do
|
||||
success Entities::CommitSignature
|
||||
end
|
||||
params do
|
||||
requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
|
||||
end
|
||||
get ':id/repository/commits/:sha/signature', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
|
||||
commit = user_project.commit(params[:sha])
|
||||
not_found! 'Commit' unless commit
|
||||
|
||||
signature = commit.signature
|
||||
not_found! 'GPG Signature' unless signature
|
||||
|
||||
present signature, with: Entities::CommitSignature
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -392,6 +392,13 @@ module API
|
|||
expose :project_id
|
||||
end
|
||||
|
||||
class CommitSignature < Grape::Entity
|
||||
expose :gpg_key_id
|
||||
expose :gpg_key_primary_keyid, :gpg_key_user_name, :gpg_key_user_email
|
||||
expose :verification_status
|
||||
expose :gpg_key_subkey_id
|
||||
end
|
||||
|
||||
class BasicRef < Grape::Entity
|
||||
expose :type, :name
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue