diff options
author | Jason Song <i@wolfogre.com> | 2023-02-21 22:42:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 08:42:07 -0600 |
commit | c8c2a31818527f7377ddb9fb111a55d0c058ebe7 (patch) | |
tree | 5ebb1653b112dbf66e00d9ec34755382cfd5c6cf /routers/api | |
parent | 1fcf96ad0166420cbdb013365ecae42e3537b42a (diff) | |
download | gitea-c8c2a31818527f7377ddb9fb111a55d0c058ebe7.tar.gz gitea-c8c2a31818527f7377ddb9fb111a55d0c058ebe7.zip |
Add force_merge to merge request and fix checking mergable (#23010)
Fix #23000.
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/pull.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index fa8b517ae7..84eebeb94d 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -767,11 +767,18 @@ func MergePullRequest(ctx *context.APIContext) { } } - manuallMerge := repo_model.MergeStyle(form.Do) == repo_model.MergeStyleManuallyMerged - force := form.ForceMerge != nil && *form.ForceMerge + manuallyMerged := repo_model.MergeStyle(form.Do) == repo_model.MergeStyleManuallyMerged + + mergeCheckType := pull_service.MergeCheckTypeGeneral + if form.MergeWhenChecksSucceed { + mergeCheckType = pull_service.MergeCheckTypeAuto + } + if manuallyMerged { + mergeCheckType = pull_service.MergeCheckTypeManually + } // start with merging by checking - if err := pull_service.CheckPullMergable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, manuallMerge, force); err != nil { + if err := pull_service.CheckPullMergable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil { if errors.Is(err, pull_service.ErrIsClosed) { ctx.NotFound() } else if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) { @@ -793,7 +800,7 @@ func MergePullRequest(ctx *context.APIContext) { } // handle manually-merged mark - if manuallMerge { + if manuallyMerged { if err := pull_service.MergedManually(pr, ctx.Doer, ctx.Repo.GitRepo, form.MergeCommitID); err != nil { if models.IsErrInvalidMergeStyle(err) { ctx.Error(http.StatusMethodNotAllowed, "Invalid merge style", fmt.Errorf("%s is not allowed an allowed merge style for this repository", repo_model.MergeStyle(form.Do))) |