fix(user): don't match a commit with an empty author email to a user (#39777) (#39780)

Backport #39777

Co-authored-by: Yunus Ozen <94426948+ozenyunus35@users.noreply.github.com>
This commit is contained in:
GiteabotandYunus Ozen authored and GitHub committed 2026-10-14 21:00:10 +02:00
1 parent 3f0aa7a01e
commit 74e7e813c3
2 files changed
+9

No files matched your search

+3
View File
@@ -1201,6 +1201,9 @@ func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, erro
noReplyAddressSuffix := "@" + strings.ToLower(setting.Service.NoReplyAddress)
for _, email := range emails {
emailLower := strings.ToLower(email)
if emailLower == "" {
continue // a commit without an author email names no user
}
needCheckEmails.Add(emailLower)
if localPart, ok := strings.CutSuffix(emailLower, noReplyAddressSuffix); ok {
name, id := parseLocalPartToNameID(localPart)
+6
View File
@@ -95,6 +95,12 @@ func TestUserEmails(t *testing.T) {
setting.Service.NoReplyAddress = "example.com"
testGetUserByEmail(t, "user1-2@example.COM", 1)
})
t.Run("EmptyEmail", func(t *testing.T) {
// A user whose email address is empty must not own commits that have no author email.
require.NoError(t, db.Insert(t.Context(), &user_model.EmailAddress{UID: 2, Email: "", LowerEmail: "", IsActivated: true}))
testGetUserByEmail(t, "", 0)
})
})
t.Run("GetUserByEmail", func(t *testing.T) {
testGetUserByEmail := func(t *testing.T, email string, uid int64) {