mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-10 11:51:33 +02:00
Backport #37508 Regression of changed behavior or Golang JSON v2 package Fix #37506 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
8a49e9d346
commit
e2b211f291
@ -20,6 +20,7 @@ import (
|
|||||||
"code.gitea.io/gitea/models/unit"
|
"code.gitea.io/gitea/models/unit"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/glob"
|
"code.gitea.io/gitea/modules/glob"
|
||||||
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/templates"
|
"code.gitea.io/gitea/modules/templates"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/routers/web/repo"
|
"code.gitea.io/gitea/routers/web/repo"
|
||||||
@ -312,10 +313,14 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateBranchProtectionPriories(ctx *context.Context) {
|
func UpdateBranchProtectionPriories(ctx *context.Context) {
|
||||||
form := web.GetForm(ctx).(*forms.ProtectBranchPriorityForm)
|
var form struct {
|
||||||
repo := ctx.Repo.Repository
|
IDs []int64 `json:"ids"`
|
||||||
|
}
|
||||||
if err := git_model.UpdateProtectBranchPriorities(ctx, repo, form.IDs); err != nil {
|
if err := json.NewDecoder(ctx.Req.Body).Decode(&form); err != nil {
|
||||||
|
ctx.JSONError("invalid argument")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := git_model.UpdateProtectBranchPriorities(ctx, ctx.Repo.Repository, form.IDs); err != nil {
|
||||||
ctx.ServerError("UpdateProtectBranchPriorities", err)
|
ctx.ServerError("UpdateProtectBranchPriorities", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1173,7 +1173,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) {
|
|||||||
m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch).
|
m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch).
|
||||||
Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost)
|
Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost)
|
||||||
m.Post("/{id}/delete", repo_setting.DeleteProtectedBranchRulePost)
|
m.Post("/{id}/delete", repo_setting.DeleteProtectedBranchRulePost)
|
||||||
m.Post("/priority", web.Bind(forms.ProtectBranchPriorityForm{}), context.RepoMustNotBeArchived(), repo_setting.UpdateBranchProtectionPriories)
|
m.Post("/priority", context.RepoMustNotBeArchived(), repo_setting.UpdateBranchProtectionPriories)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/tags", func() {
|
m.Group("/tags", func() {
|
||||||
|
|||||||
@ -202,10 +202,6 @@ func (f *ProtectBranchForm) Validate(req *http.Request, errs binding.Errors) bin
|
|||||||
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProtectBranchPriorityForm struct {
|
|
||||||
IDs []int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebhookForm form for changing web hook
|
// WebhookForm form for changing web hook
|
||||||
type WebhookForm struct {
|
type WebhookForm struct {
|
||||||
Name string `binding:"MaxSize(255)"`
|
Name string `binding:"MaxSize(255)"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user