本站源代码
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

34 lines
1.1KB

  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 commitVerification.SigningUser != nil {
  19. verification.Signer = &structs.PayloadUser{
  20. Name: commitVerification.SigningUser.Name,
  21. Email: commitVerification.SigningUser.Email,
  22. }
  23. }
  24. verification.Verified = commitVerification.Verified
  25. verification.Reason = commitVerification.Reason
  26. if verification.Reason == "" && !verification.Verified {
  27. verification.Reason = "gpg.error.not_signed_commit"
  28. }
  29. return verification
  30. }
上海开阖软件有限公司 沪ICP备12045867号-1