mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-31 20:58:59 +00:00
Show only author and co-authors without committer, and deduplicate the same user with multiple email addresses. The commit list "Author" column should not show the committer. This is somewhat misleading, and arguably showing it on the individual commit page is sufficient and consistent with other forges. The same user with multiple email addresses often happens when DEFAULT_KEEP_EMAIL_PRIVATE is enabled and Gitea does not use an actual email address by default for edits. Showing the same avatar and name twice is not helpful then. Ref #37594 Fix #38488 --- Before <img width="4088" height="2138" alt="before" src="https://github.com/user-attachments/assets/a9e919f4-72d0-495f-a0b5-ec094f148f5a" /> After <img width="4124" height="2142" alt="after" src="https://github.com/user-attachments/assets/7212e527-ab83-440a-a8a4-95b5a79b3580" /> --------- Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package gituser
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/models/user"
|
|
"gitea.dev/modules/container"
|
|
"gitea.dev/modules/git"
|
|
"gitea.dev/modules/log"
|
|
)
|
|
|
|
// AvatarStackData is the view-model for the AvatarStack render helpers. Participants[0] is
|
|
// the primary participant (commit author), painted on top; the rest follow.
|
|
type AvatarStackData struct {
|
|
Participants []*CommitParticipant
|
|
SearchByEmailLink string
|
|
}
|
|
|
|
func BuildAvatarStackData(ctx context.Context, allParticipants []*git.CommitIdentity, emailUserMap *user.EmailUserMap) *AvatarStackData {
|
|
if emailUserMap == nil {
|
|
emails := make([]string, len(allParticipants))
|
|
for i, sig := range allParticipants {
|
|
emails[i] = sig.Email
|
|
}
|
|
var err error
|
|
emailUserMap, err = user.GetUsersByEmails(ctx, emails)
|
|
if err != nil {
|
|
log.Error("GetUsersByEmails failed: %v", err)
|
|
}
|
|
}
|
|
ret := &AvatarStackData{
|
|
Participants: make([]*CommitParticipant, 0, len(allParticipants)),
|
|
}
|
|
uniqueUserIDs := make(container.Set[int64])
|
|
for _, p := range allParticipants {
|
|
var giteaUser *user.User
|
|
if emailUserMap != nil {
|
|
giteaUser = emailUserMap.GetByEmail(p.Email)
|
|
}
|
|
if giteaUser != nil {
|
|
// identities without a Gitea account can only be compared by their git identity
|
|
if !uniqueUserIDs.Add(giteaUser.ID) {
|
|
continue
|
|
}
|
|
}
|
|
ret.Participants = append(ret.Participants, &CommitParticipant{GiteaUser: giteaUser, GitIdentity: p})
|
|
}
|
|
return ret
|
|
}
|