summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorparnic <github@parnic.com>2021-03-27 09:55:40 -0500
committerGitHub <noreply@github.com>2021-03-27 15:55:40 +0100
commitf4d27498bdc615605e14f783501e1d1256cd8d22 (patch)
tree8d04695b060bd8bac65b4a0d669628fe220a23e6 /routers
parent6b836ac5f7546bc9ffb118b213dba92d3dd9ba8e (diff)
downloadgitea-f4d27498bdc615605e14f783501e1d1256cd8d22.tar.gz
gitea-f4d27498bdc615605e14f783501e1d1256cd8d22.zip
Add DefaultMergeStyle option to repository (#14789)
Fixes #12293
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/repo.go4
-rw-r--r--routers/repo/issue.go5
-rw-r--r--routers/repo/setting.go1
3 files changed, 9 insertions, 1 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index b7ed2951ad..c422feb043 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -731,6 +731,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
AllowSquash: true,
AllowManualMerge: true,
AutodetectManualMerge: false,
+ DefaultMergeStyle: models.MergeStyleMerge,
}
} else {
config = unit.PullRequestsConfig()
@@ -757,6 +758,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
if opts.AutodetectManualMerge != nil {
config.AutodetectManualMerge = *opts.AutodetectManualMerge
}
+ if opts.DefaultMergeStyle != nil {
+ config.DefaultMergeStyle = models.MergeStyle(*opts.DefaultMergeStyle)
+ }
units = append(units, models.RepoUnit{
RepoID: repo.ID,
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 15459cd0e6..c2969ca4bd 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1484,7 +1484,10 @@ func ViewIssue(ctx *context.Context) {
// Check correct values and select default
if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
!prConfig.IsMergeStyleAllowed(ms) {
- if prConfig.AllowMerge {
+ defaultMergeStyle := prConfig.GetDefaultMergeStyle()
+ if prConfig.IsMergeStyleAllowed(defaultMergeStyle) && !ok {
+ ctx.Data["MergeStyle"] = defaultMergeStyle
+ } else if prConfig.AllowMerge {
ctx.Data["MergeStyle"] = models.MergeStyleMerge
} else if prConfig.AllowRebase {
ctx.Data["MergeStyle"] = models.MergeStyleRebase
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index dc14b69b3b..8349164d4c 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -322,6 +322,7 @@ func SettingsPost(ctx *context.Context) {
AllowSquash: form.PullsAllowSquash,
AllowManualMerge: form.PullsAllowManualMerge,
AutodetectManualMerge: form.EnableAutodetectManualMerge,
+ DefaultMergeStyle: models.MergeStyle(form.PullsDefaultMergeStyle),
},
})
} else if !models.UnitTypePullRequests.UnitGlobalDisabled() {