From 75995dc946ee913b54b57826fe93b55bfc8d19f1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 22 Feb 2026 17:35:53 +0100 Subject: [PATCH 1/3] Change default "allow edits from maintainers" to true This aligns with GitHub's default behavior where the "Allow edits from maintainers" checkbox is checked by default when creating pull requests. Co-Authored-By: Claude Opus 4.6 --- models/issues/pull.go | 2 +- routers/api/v1/repo/repo.go | 2 +- routers/web/repo/compare.go | 2 +- services/convert/repository.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/models/issues/pull.go b/models/issues/pull.go index 9f180f9ac950b..b83caa0521650 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -141,7 +141,7 @@ type PullRequest struct { HeadCommitID string `xorm:"-"` BaseBranch string MergeBase string `xorm:"VARCHAR(64)"` - AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"` + AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT true"` HasMerged bool `xorm:"INDEX"` MergedCommitID string `xorm:"VARCHAR(64)"` diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index bb6bda587db6c..93c09cd8bd4dc 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -905,7 +905,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { AllowRebaseUpdate: true, DefaultDeleteBranchAfterMerge: false, DefaultMergeStyle: repo_model.MergeStyleMerge, - DefaultAllowMaintainerEdit: false, + DefaultAllowMaintainerEdit: true, } } else { config = unit.PullRequestsConfig() diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index e034731e5cd54..f325ec07255e7 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -718,7 +718,7 @@ func CompareDiff(ctx *context.Context) { config := unit.PullRequestsConfig() ctx.Data["AllowMaintainerEdit"] = config.DefaultAllowMaintainerEdit } else { - ctx.Data["AllowMaintainerEdit"] = false + ctx.Data["AllowMaintainerEdit"] = true } ctx.HTML(http.StatusOK, tplCompare) diff --git a/services/convert/repository.go b/services/convert/repository.go index 150c952b15dc3..61fbe75511088 100644 --- a/services/convert/repository.go +++ b/services/convert/repository.go @@ -102,7 +102,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR autodetectManualMerge := false defaultDeleteBranchAfterMerge := false defaultMergeStyle := repo_model.MergeStyleMerge - defaultAllowMaintainerEdit := false + defaultAllowMaintainerEdit := true defaultTargetBranch := "" if unit, err := repo.GetUnit(ctx, unit_model.TypePullRequests); err == nil { config := unit.PullRequestsConfig() From abe6bb6ea8b8c42e7e9088a552a2a69daa8d8939 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 22 Feb 2026 17:54:18 +0100 Subject: [PATCH 2/3] Add migration to set DefaultAllowMaintainerEdit to true Updates all existing repo pull request configs to set DefaultAllowMaintainerEdit to true, matching the new default. Co-Authored-By: Claude Opus 4.6 --- models/migrations/migrations.go | 1 + models/migrations/v1_26/v326.go | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 models/migrations/v1_26/v326.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 9975729fd62a7..26587cea48008 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -400,6 +400,7 @@ func prepareMigrationTasks() []*migration { newMigration(323, "Add support for actions concurrency", v1_26.AddActionsConcurrency), newMigration(324, "Fix closed milestone completeness for milestones with no issues", v1_26.FixClosedMilestoneCompleteness), newMigration(325, "Fix missed repo_id when migrate attachments", v1_26.FixMissedRepoIDWhenMigrateAttachments), + newMigration(326, "Set DefaultAllowMaintainerEdit to true", v1_26.SetDefaultAllowMaintainerEdit), } return preparedMigrations } diff --git a/models/migrations/v1_26/v326.go b/models/migrations/v1_26/v326.go new file mode 100644 index 0000000000000..c2450ca44941e --- /dev/null +++ b/models/migrations/v1_26/v326.go @@ -0,0 +1,47 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_26 + +import ( + "code.gitea.io/gitea/modules/json" + + "xorm.io/xorm" +) + +func SetDefaultAllowMaintainerEdit(x *xorm.Engine) error { + type RepoUnit struct { + ID int64 + Config string + } + + var units []RepoUnit + // type = 3 is TypePullRequests + err := x.Table("repo_unit").Where("`type` = 3").Find(&units) + if err != nil { + return err + } + + for _, unit := range units { + if unit.Config == "" { + continue + } + + var cfg map[string]any + if err := json.Unmarshal([]byte(unit.Config), &cfg); err != nil { + return err + } + + cfg["DefaultAllowMaintainerEdit"] = true + data, err := json.Marshal(cfg) + if err != nil { + return err + } + + _, err = x.Exec("UPDATE `repo_unit` SET `config` = ? WHERE `id` = ?", string(data), unit.ID) + if err != nil { + return err + } + } + return nil +} From 5c3187ce95cb52a91f246df5c9b6b3738c0b350b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 22 Feb 2026 18:29:56 +0100 Subject: [PATCH 3/3] Revert "Add migration to set DefaultAllowMaintainerEdit to true" This reverts commit abe6bb6ea8b8c42e7e9088a552a2a69daa8d8939. --- models/migrations/migrations.go | 1 - models/migrations/v1_26/v326.go | 47 --------------------------------- 2 files changed, 48 deletions(-) delete mode 100644 models/migrations/v1_26/v326.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 26587cea48008..9975729fd62a7 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -400,7 +400,6 @@ func prepareMigrationTasks() []*migration { newMigration(323, "Add support for actions concurrency", v1_26.AddActionsConcurrency), newMigration(324, "Fix closed milestone completeness for milestones with no issues", v1_26.FixClosedMilestoneCompleteness), newMigration(325, "Fix missed repo_id when migrate attachments", v1_26.FixMissedRepoIDWhenMigrateAttachments), - newMigration(326, "Set DefaultAllowMaintainerEdit to true", v1_26.SetDefaultAllowMaintainerEdit), } return preparedMigrations } diff --git a/models/migrations/v1_26/v326.go b/models/migrations/v1_26/v326.go deleted file mode 100644 index c2450ca44941e..0000000000000 --- a/models/migrations/v1_26/v326.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2026 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -package v1_26 - -import ( - "code.gitea.io/gitea/modules/json" - - "xorm.io/xorm" -) - -func SetDefaultAllowMaintainerEdit(x *xorm.Engine) error { - type RepoUnit struct { - ID int64 - Config string - } - - var units []RepoUnit - // type = 3 is TypePullRequests - err := x.Table("repo_unit").Where("`type` = 3").Find(&units) - if err != nil { - return err - } - - for _, unit := range units { - if unit.Config == "" { - continue - } - - var cfg map[string]any - if err := json.Unmarshal([]byte(unit.Config), &cfg); err != nil { - return err - } - - cfg["DefaultAllowMaintainerEdit"] = true - data, err := json.Marshal(cfg) - if err != nil { - return err - } - - _, err = x.Exec("UPDATE `repo_unit` SET `config` = ? WHERE `id` = ?", string(data), unit.ID) - if err != nil { - return err - } - } - return nil -}