diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/repo.go | 4 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 15 | ||||
-rw-r--r-- | routers/web/repo/setting/setting.go | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 93d40d2dbf..04c6fde453 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -937,6 +937,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { AllowRebaseUpdate: true, DefaultDeleteBranchAfterMerge: false, DefaultMergeStyle: repo_model.MergeStyleMerge, + DefaultUpdateStyle: repo_model.UpdateStyleMerge, DefaultAllowMaintainerEdit: false, } } else { @@ -976,6 +977,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { if opts.DefaultMergeStyle != nil { config.DefaultMergeStyle = repo_model.MergeStyle(*opts.DefaultMergeStyle) } + if opts.DefaultUpdateStyle != nil { + config.DefaultUpdateStyle = repo_model.UpdateStyle(*opts.DefaultUpdateStyle) + } if opts.DefaultAllowMaintainerEdit != nil { config.DefaultAllowMaintainerEdit = *opts.DefaultAllowMaintainerEdit } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 78fb5e6c01..c154a9b665 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1918,6 +1918,21 @@ func ViewIssue(ctx *context.Context) { ctx.Data["MergeStyle"] = mergeStyle + var updateStyle repo_model.UpdateStyle + // Check correct values and select default + if ms, ok := ctx.Data["UpdateStyle"].(repo_model.UpdateStyle); !ok || + !prConfig.IsUpdateStyleAllowed(ms) { + defaultUpdateStyle := prConfig.GetDefaultUpdateStyle() + if prConfig.IsUpdateStyleAllowed(defaultUpdateStyle) && !ok { + updateStyle = defaultUpdateStyle + } else if prConfig.AllowMerge { + updateStyle = repo_model.UpdateStyleMerge + } else if prConfig.AllowRebase { + updateStyle = repo_model.UpdateStyleRebase + } + } + ctx.Data["UpdateStyle"] = updateStyle + defaultMergeMessage, defaultMergeBody, err := pull_service.GetDefaultMergeMessage(ctx, ctx.Repo.GitRepo, pull, mergeStyle) if err != nil { ctx.ServerError("GetDefaultMergeMessage", err) diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index ce506eafb1..2c6ca77a6a 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -262,6 +262,7 @@ func UnitsPost(ctx *context.Context) { AllowRebaseUpdate: form.PullsAllowRebaseUpdate, DefaultDeleteBranchAfterMerge: form.DefaultDeleteBranchAfterMerge, DefaultMergeStyle: repo_model.MergeStyle(form.PullsDefaultMergeStyle), + DefaultUpdateStyle: repo_model.UpdateStyle(form.PullsDefaultUpdateStyle), DefaultAllowMaintainerEdit: form.DefaultAllowMaintainerEdit, }, }) |