diff options
author | endo0911engineer <161911062+endo0911engineer@users.noreply.github.com> | 2025-06-18 04:05:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-17 12:05:10 -0700 |
commit | 1376cf7481bfdb6ff7089eb8917bc0d47d17a56a (patch) | |
tree | 9ccb5c178c0c7cfa8cf29b23cc2fa7b3df5349ab | |
parent | f214bb40a3f65631f5c36af3e5ebf926badf82f7 (diff) | |
download | gitea-1376cf7481bfdb6ff7089eb8917bc0d47d17a56a.tar.gz gitea-1376cf7481bfdb6ff7089eb8917bc0d47d17a56a.zip |
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>
-rw-r--r-- | routers/web/repo/compare.go | 8 |
1 files changed, 7 insertions, 1 deletions
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 { |