Add API endpoint to get a commit's GPG signature

This commit is contained in:
Balasankar "Balu" C 2019-02-07 22:39:14 +05:30
parent c6016ac8a8
commit 034d1d02b9
No known key found for this signature in database
GPG Key ID: B77D2E2E23735427
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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