From 6f5f0be9e34230b098232db024d0416be0b0e8e0 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 18 Jun 2025 07:16:36 +0800 Subject: [PATCH] Support title and body query parameters for new PRs (#34537) (#34752) Backport #34537 by endo0911engineer Co-authored-by: endo0911engineer <161911062+endo0911engineer@users.noreply.github.com> Co-authored-by: wxiaoguang --- routers/web/repo/compare.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 15200ff997..f47af0aae7 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -574,7 +574,13 @@ func PrepareCompareDiff( ctx.Data["CommitRepoLink"] = ci.HeadRepo.Link() ctx.Data["AfterCommitID"] = headCommitID - ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand") + + // follow GitHub's behavior: autofill the form and expand + newPrFormTitle := ctx.FormTrim("title") + newPrFormBody := ctx.FormTrim("body") + ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand") || ctx.FormBool("quick_pull") || newPrFormTitle != "" || newPrFormBody != "" + ctx.Data["TitleQuery"] = newPrFormTitle + ctx.Data["BodyQuery"] = newPrFormBody if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) || headCommitID == ci.CompareInfo.BaseCommitID {