Backport #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: Nicolas <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -6,7 +6,6 @@ package setting
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/actions"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
@@ -94,15 +93,12 @@ func ActionsUnitPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func AddCollaborativeOwner(ctx *context.Context) {
|
||||
name := strings.ToLower(ctx.FormString("collaborative_owner"))
|
||||
|
||||
ownerID, err := user_model.GetUserOrOrgIDByName(ctx, name)
|
||||
collUser, err := user_model.GetUserByName(ctx, ctx.FormString("collaborative_owner"))
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
||||
ctx.JSONErrorNotFound()
|
||||
ctx.JSONError(ctx.Tr("form.user_not_exist"))
|
||||
} else {
|
||||
ctx.ServerError("GetUserOrOrgIDByName", err)
|
||||
ctx.ServerError("GetUserByName", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -113,7 +109,7 @@ func AddCollaborativeOwner(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
actionsCfg := actionsUnit.ActionsConfig()
|
||||
actionsCfg.AddCollaborativeOwner(ownerID)
|
||||
actionsCfg.AddCollaborativeOwner(collUser.ID)
|
||||
if err := repo_model.UpdateRepoUnitConfig(ctx, actionsUnit); err != nil {
|
||||
ctx.ServerError("UpdateRepoUnitConfig", err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user