gitea源码

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {{/* Template attributes:
  2. * Commit
  3. * CommitBaseLink
  4. * CommitSignVerification
  5. If you'd like to modify this template, you could test it on the devtest page.
  6. ATTENTION: this template could be re-rendered many times (on the graph and commit list page),
  7. so this template should be kept as small as possible, DO NOT put large components like modal/dialog into it.
  8. */}}
  9. {{- $commit := $.Commit -}}
  10. {{- $commitBaseLink := $.CommitBaseLink -}}
  11. {{- $verification := $.CommitSignVerification -}}{{- /* asymkey.CommitVerification */ -}}
  12. {{- $extraClass := "" -}}
  13. {{- $verified := false -}}
  14. {{- $signingUser := NIL -}}
  15. {{- $signingEmail := "" -}}
  16. {{- $msgReasonPrefix := "" -}}
  17. {{- $msgReason := "" -}}
  18. {{- $msgSigningKey := "" -}}
  19. {{- if $verification -}}
  20. {{- $signingUser = $verification.SigningUser -}}
  21. {{- $signingEmail = $verification.SigningEmail -}}
  22. {{- $extraClass = print $extraClass " commit-is-signed" -}}
  23. {{- if $verification.Verified -}}
  24. {{- /* reason is "{name} / {key-id}" */ -}}
  25. {{- $msgReason = $verification.Reason -}}
  26. {{- $verified = true -}}
  27. {{- if eq $verification.TrustStatus "trusted" -}}
  28. {{- $extraClass = print $extraClass " sign-trusted" -}}
  29. {{- else if eq $verification.TrustStatus "untrusted" -}}
  30. {{- $extraClass = print $extraClass " sign-untrusted" -}}
  31. {{- $msgReasonPrefix = ctx.Locale.Tr "repo.commits.signed_by_untrusted_user" -}}
  32. {{- else -}}
  33. {{- $extraClass = print $extraClass " sign-unmatched" -}}
  34. {{- $msgReasonPrefix = ctx.Locale.Tr "repo.commits.signed_by_untrusted_user_unmatched" -}}
  35. {{- end -}}
  36. {{- else -}}
  37. {{- if $verification.Warning -}}
  38. {{- $extraClass = print $extraClass " sign-warning" -}}
  39. {{- else -}}
  40. {{- $extraClass = "" -}}{{/* the commit is not signed */}}
  41. {{- end -}}
  42. {{- $msgReason = ctx.Locale.Tr $verification.Reason -}}{{- /* dirty part: it is the translation key ..... */ -}}
  43. {{- end -}}
  44. {{- if $msgReasonPrefix -}}
  45. {{- $msgReason = print $msgReasonPrefix ": " $msgReason -}}
  46. {{- end -}}
  47. {{- if $verification.SigningSSHKey -}}
  48. {{- $msgSigningKey = print (ctx.Locale.Tr "repo.commits.ssh_key_fingerprint") ": " $verification.SigningSSHKey.Fingerprint -}}
  49. {{- else if $verification.SigningKey -}}{{- /* asymkey.GPGKey */ -}}
  50. {{- $msgSigningKey = print (ctx.Locale.Tr "repo.commits.gpg_key_id") ": " $verification.SigningKey.PaddedKeyID -}}
  51. {{- end -}}
  52. {{- end -}}
  53. {{- if $commit -}}
  54. <a {{if $commitBaseLink}}href="{{$commitBaseLink}}/{{$commit.ID}}"{{end}} class="ui label commit-id-short {{$extraClass}}" rel="nofollow">
  55. {{- ShortSha $commit.ID.String -}}
  56. {{- end -}}
  57. {{- if or (not $commit) $extraClass}}{{/* only show the lock icon if there is no commit info (icon only) or the commit is really signed */}}
  58. <span class="ui label commit-sign-badge {{$extraClass}}">
  59. {{- if $verified -}}
  60. {{- if and $signingUser $signingUser.ID -}}
  61. <span data-tooltip-content="{{$msgReason}}">{{svg "gitea-lock"}}</span>
  62. <span data-tooltip-content="{{$msgSigningKey}}">{{ctx.AvatarUtils.Avatar $signingUser 16}}</span>
  63. {{- else -}}
  64. <span data-tooltip-content="{{$msgReason}}">{{svg "gitea-lock-cog"}}</span>
  65. <span data-tooltip-content="{{$msgSigningKey}}">{{ctx.AvatarUtils.AvatarByEmail $signingEmail "" 16}}</span>
  66. {{- end -}}
  67. {{- else -}}
  68. <span data-tooltip-content="{{$msgReason}}">{{svg "gitea-unlock"}}</span>
  69. {{- end -}}
  70. </span>
  71. {{- end -}}
  72. {{- if $commit -}}
  73. </a>
  74. {{- end -}}
  75. {{- /* This template should be kept as small as possible, DO NOT put large components like modal/dialog into it. */ -}}