Skip to content

Commit fd9c7da

Browse files
endo0911engineerrootwxiaoguang
authored andcommitted
Support title and body query parameters for new PRs (go-gitea#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 <[email protected]>
1 parent 23d2d22 commit fd9c7da

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
@@ -574,7 +574,13 @@ func PrepareCompareDiff(
574574

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

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

0 commit comments

Comments
 (0)