1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Move checks for pulls before merge into own function (#19271)

This make checks in one single place so they dont differ and maintainer can not forget a check in one place while adding it to the other .... ( as it's atm )

Fix:
* The API does ignore issue dependencies where Web does not
* The API checks if "IsSignedIfRequired" where Web does not - UI probably do but nothing will some to craft custom requests
* Default merge message is crafted a bit different between API and Web if not set on specific cases ...
This commit is contained in:
6543
2022-03-31 16:53:08 +02:00
committed by GitHub
parent f6145a69c4
commit 9c349a4277
9 changed files with 217 additions and 211 deletions

View File

@@ -599,6 +599,31 @@ func (f *MergePullRequestForm) Validate(req *http.Request, errs binding.Errors)
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}
// SetDefaults if not provided for mergestyle and commit message
func (f *MergePullRequestForm) SetDefaults(pr *models.PullRequest) (err error) {
if f.Do == "" {
f.Do = "merge"
}
f.MergeTitleField = strings.TrimSpace(f.MergeTitleField)
if len(f.MergeTitleField) == 0 {
switch f.Do {
case "merge", "rebase-merge":
f.MergeTitleField, err = pr.GetDefaultMergeMessage()
case "squash":
f.MergeTitleField, err = pr.GetDefaultSquashMessage()
}
}
f.MergeMessageField = strings.TrimSpace(f.MergeMessageField)
if len(f.MergeMessageField) > 0 {
f.MergeTitleField += "\n\n" + f.MergeMessageField
f.MergeMessageField = ""
}
return
}
// CodeCommentForm form for adding code comments for PRs
type CodeCommentForm struct {
Origin string `binding:"Required;In(timeline,diff)"`