Skip to content

Commit ab62f4e

Browse files
committed
Fix bug
1 parent 602be74 commit ab62f4e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

models/user/user.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,15 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) ([
11461146
}
11471147

11481148
for _, c := range oldCommits {
1149+
user, ok := emailUserMap[c.Author.Email]
1150+
if !ok {
1151+
user = &User{
1152+
Name: c.Author.Name,
1153+
Email: c.Author.Email,
1154+
}
1155+
}
11491156
newCommits = append(newCommits, &UserCommit{
1150-
User: emailUserMap[c.Author.Email],
1157+
User: user,
11511158
Commit: c,
11521159
})
11531160
}
@@ -1187,7 +1194,11 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
11871194

11881195
results := make(map[string]*User, len(emails))
11891196
for _, user := range users {
1190-
results[user.Email] = user
1197+
if user.KeepEmailPrivate {
1198+
results[user.LowerName+"@"+setting.Service.NoReplyAddress] = user
1199+
} else {
1200+
results[user.Email] = user
1201+
}
11911202
}
11921203
users = make([]*User, 0, len(needCheckUserNames))
11931204
if err := db.GetEngine(ctx).In("lower_name", needCheckUserNames.Values()).Find(&users); err != nil {

0 commit comments

Comments
 (0)