mirror of
https://github.com/go-gitea/gitea.git
synced 2025-02-20 11:43:57 +08:00
Merge d7d01946aebad337ace5873f1e3415448ab5c847 into 21af8150b7ba315a9f75264ab77813b0b7c697a8
This commit is contained in:
commit
eb28adadea
@ -43,9 +43,11 @@ func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML {
|
|||||||
|
|
||||||
switch t := item.(type) {
|
switch t := item.(type) {
|
||||||
case *user_model.User:
|
case *user_model.User:
|
||||||
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
|
if t != nil && t.ID != 0 {
|
||||||
if src != "" {
|
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
|
||||||
return AvatarHTML(src, size, class, t.DisplayName())
|
if src != "" {
|
||||||
|
return AvatarHTML(src, size, class, t.DisplayName())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *repo_model.Collaborator:
|
case *repo_model.Collaborator:
|
||||||
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
|
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
|
||||||
|
@ -5,6 +5,7 @@ package git
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
@ -18,9 +19,6 @@ import (
|
|||||||
|
|
||||||
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
|
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
|
||||||
func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.UserCommit, repoTrustModel repo_model.TrustModelType, isOwnerMemberCollaborator func(*user_model.User) (bool, error)) ([]*asymkey_model.SignCommit, error) {
|
func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.UserCommit, repoTrustModel repo_model.TrustModelType, isOwnerMemberCollaborator func(*user_model.User) (bool, error)) ([]*asymkey_model.SignCommit, error) {
|
||||||
newCommits := make([]*asymkey_model.SignCommit, 0, len(oldCommits))
|
|
||||||
keyMap := map[string]bool{}
|
|
||||||
|
|
||||||
emails := make(container.Set[string])
|
emails := make(container.Set[string])
|
||||||
for _, c := range oldCommits {
|
for _, c := range oldCommits {
|
||||||
if c.Committer != nil {
|
if c.Committer != nil {
|
||||||
@ -33,6 +31,9 @@ func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.Use
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newCommits := make([]*asymkey_model.SignCommit, 0, len(oldCommits))
|
||||||
|
keyMap := map[string]bool{}
|
||||||
|
cachedVerifications := make(map[string]*asymkey_model.CommitVerification)
|
||||||
for _, c := range oldCommits {
|
for _, c := range oldCommits {
|
||||||
committer, ok := emailUsers[c.Committer.Email]
|
committer, ok := emailUsers[c.Committer.Email]
|
||||||
if !ok && c.Committer != nil {
|
if !ok && c.Committer != nil {
|
||||||
@ -42,9 +43,19 @@ func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.Use
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key := committer.Email
|
||||||
|
if c.Signature != nil {
|
||||||
|
key += fmt.Sprintf("-%s", c.Signature.Signature)
|
||||||
|
}
|
||||||
|
verification, ok := cachedVerifications[key]
|
||||||
|
if !ok {
|
||||||
|
verification = asymkey_service.ParseCommitWithSignatureCommitter(ctx, c.Commit, committer)
|
||||||
|
cachedVerifications[key] = verification
|
||||||
|
}
|
||||||
|
|
||||||
signCommit := &asymkey_model.SignCommit{
|
signCommit := &asymkey_model.SignCommit{
|
||||||
UserCommit: c,
|
UserCommit: c,
|
||||||
Verification: asymkey_service.ParseCommitWithSignatureCommitter(ctx, c.Commit, committer),
|
Verification: verification,
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = asymkey_model.CalculateTrustStatus(signCommit.Verification, repoTrustModel, isOwnerMemberCollaborator, &keyMap)
|
_ = asymkey_model.CalculateTrustStatus(signCommit.Verification, repoTrustModel, isOwnerMemberCollaborator, &keyMap)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user