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.

verification.go 911B

1234567891011121314151617181920212223242526272829
  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/gitea/modules/structs"
  9. )
  10. // GetPayloadCommitVerification returns the verification information of a commit
  11. func GetPayloadCommitVerification(commit *git.Commit) *structs.PayloadCommitVerification {
  12. verification := &structs.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. }