From 1376cf7481bfdb6ff7089eb8917bc0d47d17a56a Mon Sep 17 00:00:00 2001 From: endo0911engineer <161911062+endo0911engineer@users.noreply.github.com> Date: Wed, 18 Jun 2025 04:05:10 +0900 Subject: [PATCH] Support title and body query parameters for new PRs (#34537) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 8b99dd95da..de34a9375c 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -575,7 +575,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 {