Skip to content

Support title and body query parameters for new PRs #34537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions routers/web/repo/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,22 @@
ctx.Data["AfterCommitID"] = headCommitID
ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand")

formTitle := ctx.FormString("title")
formBody := ctx.FormString("body")
quickPull := ctx.FormBool("quick_pull")

Check failure on line 583 in routers/web/repo/compare.go

View workflow job for this annotation

GitHub Actions / lint-backend

File is not properly formatted (gofmt)

Check failure on line 583 in routers/web/repo/compare.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

File is not properly formatted (gofmt)

Check failure on line 583 in routers/web/repo/compare.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

File is not properly formatted (gofmt)
if formTitle != "" {
ctx.Data["TitleQuery"] = formTitle
}

if formBody != "" {
ctx.Data["BodyQuery"] = formBody
}

if ctx.Data["ExpandNewPrForm"] != true && (quickPull || formTitle != "" || formBody != "") {
ctx.Data["ExpandNewPrForm"] = true
}

if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) ||
headCommitID == ci.CompareInfo.BaseCommitID {
ctx.Data["IsNothingToCompare"] = true
Expand Down Expand Up @@ -804,6 +820,21 @@
if ctx.Written() {
return
}

title := ctx.FormString("title")
body := ctx.FormString("body")
expandNewPRForm := ctx.FormBool("quick_pull")

if title != "" {
ctx.Data["TitleQuery"] = title
}
if body != "" {
ctx.Data["BodyQuery"] = body
}
if expandNewPRForm || title != "" || body != "" {
ctx.Data["ExpandNewPrForm"] = true
}

_, templateErrs := setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates, pageMetaData)
if len(templateErrs) > 0 {
ctx.Flash.Warning(renderErrorOfTemplates(ctx, templateErrs), true)
Expand Down
Loading