You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
895 B

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repofiles
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/git"
  8. "code.gitea.io/sdk/gitea"
  9. )
  10. // GetPayloadCommitVerification returns the verification information of a commit
  11. func GetPayloadCommitVerification(commit *git.Commit) *gitea.PayloadCommitVerification {
  12. verification := &gitea.PayloadCommitVerification{}
  13. commitVerification := models.ParseCommitWithSignature(commit)
  14. if commit.Signature != nil {
  15. verification.Signature = commit.Signature.Signature
  16. verification.Payload = commit.Signature.Payload
  17. }
  18. if verification.Reason != "" {
  19. verification.Reason = commitVerification.Reason
  20. } else {
  21. if verification.Verified {
  22. verification.Reason = "unsigned"
  23. }
  24. }
  25. return verification
  26. }