@@ -93,9 +93,7 @@ func (graph *Graph) AddCommit(row, column int, flowID int64, data []byte) error
9393// before finally retrieving the latest status
9494func (graph * Graph ) LoadAndProcessCommits (ctx context.Context , repository * repo_model.Repository , gitRepo * git.Repository ) error {
9595 var err error
96- var ok bool
97-
98- emails := map [string ]* user_model.User {}
96+ emailSet := map [string ]struct {}{}
9997 keyMap := map [string ]bool {}
10098
10199 for _ , c := range graph .Commits {
@@ -106,13 +104,44 @@ func (graph *Graph) LoadAndProcessCommits(ctx context.Context, repository *repo_
106104 if err != nil {
107105 return fmt .Errorf ("GetCommit: %s Error: %w" , c .Rev , err )
108106 }
109-
110107 if c .Commit .Author != nil {
111- email := c .Commit .Author .Email
112- if c .User , ok = emails [email ]; ! ok {
113- c .User , _ = user_model .GetUserByEmail (ctx , email )
114- emails [email ] = c .User
108+ emailSet [c .Commit .Author .Email ] = struct {}{}
109+ }
110+ for _ , sig := range c .Commit .CoAuthorSignatures () {
111+ emailSet [sig .Email ] = struct {}{}
112+ }
113+ }
114+
115+ allEmails := make ([]string , 0 , len (emailSet ))
116+ for email := range emailSet {
117+ allEmails = append (allEmails , email )
118+ }
119+ var emailUserMap * user_model.EmailUserMap
120+ if len (allEmails ) > 0 {
121+ emailUserMap , err = user_model .GetUsersByEmails (ctx , allEmails )
122+ if err != nil {
123+ log .Error ("GetUsersByEmails: %v" , err )
124+ }
125+ }
126+
127+ for _ , c := range graph .Commits {
128+ if c .Commit == nil {
129+ continue
130+ }
131+ if c .Commit .Author != nil && emailUserMap != nil {
132+ c .User = emailUserMap .GetByEmail (c .Commit .Author .Email )
133+ }
134+ coAuthorSigs := c .Commit .CoAuthorSignatures ()
135+ c .CoAuthors = make ([]* user_model.CoAuthorUser , 0 , len (coAuthorSigs ))
136+ for _ , sig := range coAuthorSigs {
137+ var giteaUser * user_model.User
138+ if emailUserMap != nil {
139+ giteaUser = emailUserMap .GetByEmail (sig .Email )
115140 }
141+ c .CoAuthors = append (c .CoAuthors , & user_model.CoAuthorUser {
142+ GiteaUser : giteaUser ,
143+ TrailerSignature : sig ,
144+ })
116145 }
117146
118147 c .Verification = asymkey_service .ParseCommitWithSignature (ctx , c .Commit )
@@ -248,6 +277,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
248277type Commit struct {
249278 Commit * git.Commit
250279 User * user_model.User
280+ CoAuthors []* user_model.CoAuthorUser
251281 Verification * asymkey_model.CommitVerification
252282 Status * git_model.CommitStatus
253283 Flow int64
0 commit comments