Skip to content

Commit 1376cf7

Browse files
endo0911engineerrootwxiaoguang
authored
Support title and body query parameters for new PRs (#34537)
Currently, Gitea supports title and body query parameters when creating new issues, allowing pre-filling those fields via URL parameters. However, similar support for pull requests (PRs) does not exist. This feature adds support for the title, body, and quick_pull query parameters in the new pull request creation page. These parameters work similarly to GitHub’s behavior, allowing users to pre-populate the PR title and body, and optionally expand the PR creation form automatically. By supporting these query parameters, it improves the usability and automation capabilities when creating pull requests via direct URLs, aligning Gitea more closely with GitHub’s user experience. --------- Co-authored-by: root <root@DESKTOP-UPANUTP> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent f214bb4 commit 1376cf7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

routers/web/repo/compare.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,13 @@ func PrepareCompareDiff(
575575

576576
ctx.Data["CommitRepoLink"] = ci.HeadRepo.Link()
577577
ctx.Data["AfterCommitID"] = headCommitID
578-
ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand")
578+
579+
// follow GitHub's behavior: autofill the form and expand
580+
newPrFormTitle := ctx.FormTrim("title")
581+
newPrFormBody := ctx.FormTrim("body")
582+
ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand") || ctx.FormBool("quick_pull") || newPrFormTitle != "" || newPrFormBody != ""
583+
ctx.Data["TitleQuery"] = newPrFormTitle
584+
ctx.Data["BodyQuery"] = newPrFormBody
579585

580586
if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) ||
581587
headCommitID == ci.CompareInfo.BaseCommitID {

0 commit comments

Comments
 (0)