fix: use consistent GetUser family functions (#37553)

fixes adding collaborative owners in Actions settings when the user or
organization name contains capital letters.

Fixes #37548

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Nicolas
2026-05-07 08:10:19 +02:00
committed by GitHub
parent 19f01691d5
commit 2200ed7499
4 changed files with 30 additions and 57 deletions
+8 -4
View File
@@ -6,6 +6,7 @@ package migrations
import (
"context"
"errors"
"fmt"
"io"
"strconv"
@@ -989,12 +990,15 @@ func (g *GiteaLocalUploader) remapUser(ctx context.Context, source user_model.Ex
func (g *GiteaLocalUploader) remapLocalUser(ctx context.Context, source user_model.ExternalUserMigrated) (int64, error) {
userid, ok := g.userMap[source.GetExternalID()]
if !ok {
name, err := user_model.GetUserNameByID(ctx, source.GetExternalID())
if err != nil {
user, err := user_model.GetUserByID(ctx, source.GetExternalID())
if errors.Is(err, util.ErrNotExist) {
g.userMap[source.GetExternalID()] = userid
return 0, nil
} else if err != nil {
return 0, err
}
// let's not reuse an ID when the user was deleted or has a different user name
if name != source.GetExternalName() {
// let's not reuse an ID when the user was deleted or has a different username
if !util.AsciiEqualFold(user.Name, source.GetExternalName()) {
userid = 0
} else {
userid = source.GetExternalID()