@@ -1151,8 +1151,8 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) ([
11511151 }
11521152
11531153 for _ , c := range oldCommits {
1154- user , ok := emailUserMap [ c .Author .Email ]
1155- if ! ok {
1154+ user := emailUserMap . GetByEmail ( c .Author .Email )
1155+ if user == nil {
11561156 user = & User {
11571157 Name : c .Author .Name ,
11581158 Email : c .Author .Email ,
@@ -1166,7 +1166,15 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) ([
11661166 return newCommits , nil
11671167}
11681168
1169- func GetUsersByEmails (ctx context.Context , emails []string ) (map [string ]* User , error ) {
1169+ type EmailUserMap struct {
1170+ m map [string ]* User
1171+ }
1172+
1173+ func (eum * EmailUserMap ) GetByEmail (email string ) * User {
1174+ return eum .m [strings .ToLower (email )]
1175+ }
1176+
1177+ func GetUsersByEmails (ctx context.Context , emails []string ) (* EmailUserMap , error ) {
11701178 if len (emails ) == 0 {
11711179 return nil , nil
11721180 }
@@ -1176,7 +1184,7 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
11761184 for _ , email := range emails {
11771185 if strings .HasSuffix (email , "@" + setting .Service .NoReplyAddress ) {
11781186 username := strings .TrimSuffix (email , "@" + setting .Service .NoReplyAddress )
1179- needCheckUserNames .Add (username )
1187+ needCheckUserNames .Add (strings . ToLower ( username ) )
11801188 } else {
11811189 needCheckEmails .Add (strings .ToLower (email ))
11821190 }
@@ -1203,8 +1211,7 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
12031211 for _ , email := range emailAddresses {
12041212 user := users [email .UID ]
12051213 if user != nil {
1206- results [user .Email ] = user
1207- results [user .GetPlaceholderEmail ()] = user
1214+ results [email .Email ] = user
12081215 }
12091216 }
12101217 }
@@ -1214,10 +1221,9 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
12141221 return nil , err
12151222 }
12161223 for _ , user := range users {
1217- results [user .Email ] = user
12181224 results [user .GetPlaceholderEmail ()] = user
12191225 }
1220- return results , nil
1226+ return & EmailUserMap { results } , nil
12211227}
12221228
12231229// GetUserByEmail returns the user object by given e-mail if exists.
0 commit comments