0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-06 14:58:32 +02:00

Fix update branch protection order (#37508)

Regression of changed behavior or Golang JSON v2 package

Fix #37506
This commit is contained in:
wxiaoguang 2026-05-03 00:32:36 +08:00 committed by GitHub
parent 134e86c78c
commit a2a5ef8d0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View File

@ -20,6 +20,7 @@ import (
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/glob"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/web/repo"
@ -312,10 +313,14 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
}
func UpdateBranchProtectionPriories(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.ProtectBranchPriorityForm)
repo := ctx.Repo.Repository
if err := git_model.UpdateProtectBranchPriorities(ctx, repo, form.IDs); err != nil {
var form struct {
IDs []int64 `json:"ids"`
}
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)
return
}

View File

@ -1175,7 +1175,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) {
m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch).
Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost)
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() {

View File

@ -202,10 +202,6 @@ func (f *ProtectBranchForm) Validate(req *http.Request, errs binding.Errors) bin
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}
type ProtectBranchPriorityForm struct {
IDs []int64
}
// WebhookForm form for changing web hook
type WebhookForm struct {
Name string `binding:"MaxSize(255)"`