mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package gituser
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/git/models/user"
|
|
"github.com/hanzoai/git/modules/git"
|
|
"github.com/hanzoai/git/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)),
|
|
}
|
|
for _, p := range allParticipants {
|
|
var gitUser *user.User
|
|
if emailUserMap != nil {
|
|
gitUser = emailUserMap.GetByEmail(p.Email)
|
|
}
|
|
ret.Participants = append(ret.Participants, &CommitParticipant{User: gitUser, GitIdentity: p})
|
|
}
|
|
return ret
|
|
}
|