Repository navigation
gh pr create --web now always overwrites autofilled content #11277
Description
Activity
Thank you for raising this concern up and my apologies for the problem, @bewuethr! 🙇 Let me dig into this a little deeper to assess the original PR and the information provided.
Expand for my regression testing notes
[!NOTE]
Testing againstv2.74.2using local build:gh repo clone cli/cli cd cli git checkout v2.74.2 make alias gh=$(realpath bin/gh)
Base line
- Repository: https://github.com/tinyfists/gh-pr-test
- Single-commit Branch: https://github.com/tinyfists/gh-pr-test/tree/cli/cli%2310547
commit 105da155145786b2ac621c9a3816d0f9a5016a10 (HEAD -> cli/cli#10547, origin/cli/cli#10547) Author: Andy Feller <[email protected]> Date: Mon Jul 14 14:03:37 2025 -0400 Simple change for testing This is a simple ... `.hd` file? ... whatever, let's go test `gh pr create`!
- Multi-commit Branch: https://github.com/tinyfists/gh-pr-test/tree/cli/cli%2310547-multi
commit 9bdd7a6ad73c9be7fc2b0f5fe50933644c0b9717 (HEAD -> cli/cli#10547-multi, origin/cli/cli#10547-multi) Author: Andy Feller <[email protected]> Date: Mon Jul 14 15:19:39 2025 -0400 Fix filename and added more changes commit 105da155145786b2ac621c9a3816d0f9a5016a10 (origin/cli/cli#10547, cli/cli#10547) Author: Andy Feller <[email protected]> Date: Mon Jul 14 14:03:37 2025 -0400 Simple change for testing This is a simple ... `.hd` file? ... whatever, let's go test `gh pr create`!
- Default PR Template: https://github.com/tinyfists/gh-pr-test/blob/main/.github/pull_request_template.md
## This is pre-filled content from pull request template This is being used to explore the implications of cli/cli#11277 with various `gh pr create` flags / use cases.
- Non-standard PR Template: https://github.com/tinyfists/gh-pr-test/blob/main/.github/PULL_REQUEST_TEMPLATE/nonstandard.md
## This is the non-standard pull request template Normally, creating PRs should use `.github/pull_request_template.md` if not specified if not one of the other places that the default PR template can be captured. This is meant to demonstrate where the default template is used versus a non-standard template.
Testing
v2.74.2against single-commit branchcli/cli#10547-
gh pr create --weblaunches pull request where the UI defaults the title and body based on the commit combined with default pull request template
-
gh pr create --web --title "Title from a flag"launches pull request withtitleparameter where the UI uses the title from the flag and the body based on the commit combined with default pull request template
-
gh pr create --web --body "Body from a flag"launches pull request withbodyparameter where the UI defaults the title based on the commit and the body from the flag, no template used
-
gh pr create --web --template nonstandard.mdlaunches pull request withtemplateparameter where the UI uses the title from the flag and the body based on the commit combined with non-standard pull request template
Testing
v2.74.2against multi-commit branchcli/cli#10547-multi-
gh pr create --weblaunches pull request where the UI defaults the title to " + multi" and body based on the default pull request template
-
gh pr create --web --title "Title from a flag"launches pull request withtitleparameter where the UI uses the title from the flag and the body based on the default pull request template
-
gh pr create --web --body "Body from a flag"launches pull request withbodyparameter where the UI defaults the title to " + multi" and body from the flag
-
gh pr create --web --template nonstandard.mdlaunches pull request withtemplateparameter where the UI defaults the title to " + multi" and body based on the non-standard pull request template
Testing
v2.75.0against single-commit branchcli/cli#10547-
gh pr create --weblaunches pull request withtitleandbodyparameters
Reacted by Benjamin Wuethrich and Austin OrthI am also running into this behavior. Slowing my workflow down considerably, so kudos to whomever is able to resolve. Here are versions:
gh version 2.75.0 (2025-07-09) https://github.com/cli/cli/releases/tag/v2.75.0@bewuethr @austinorth: I've been putting together regression notes (see above) and discussing this with maintainers and figuring out a path forward.
Reacted by Austin Orth and Benjamin WuethrichFollow up
TLDR
- Fix:
gh pr createprioritize--titleand--bodyover--fillwhen--webis present #10547 changes have highlighted a non-obvious side effect for affectinggh pr create --webexperiences - Fix:
gh pr createprioritize--titleand--bodyover--fillwhen--webis present #10547 is going to be reverted andv2.75.1hotfix released to unblock users gh pr create --webdoes not respecttitleandbodyarguments #10527 will be reopened with this new context to determine an appropriate fix as well as additional tests to ensure this works as expected
cc: @simon-isler
Regression explained
I believe this regression is due to unexpected side effect in the previous
gh pr create --webcode related to the logic of generating title and body from local commits.Under the covers,
gh pr createcallsinitDefaultTitleBody(...)to determine a default title and body based on local git commits, which are stored in the issue metadata state type:cli/pkg/cmd/pr/create/create.go
Lines 386 to 418 in 798d903
state, err := NewIssueState(*ctx, *opts) if err != nil { return err } if opts.TitleProvided { state.Title = opts.Title } if opts.BodyProvided { state.Body = opts.Body } var openURL string if opts.WebMode { if opts.Template != "" { state.Template = opts.Template } err = handlePush(*opts, *ctx) if err != nil { return err } openURL, err = generateCompareURL(*ctx, *state, projectsV1Support) if err != nil { return err } if !shared.ValidURL(openURL) { err = fmt.Errorf("cannot open in browser: maximum URL length exceeded") return err } return previewPR(*opts, openURL) } cli/pkg/cmd/pr/create/create.go
Lines 625 to 655 in 798d903
func NewIssueState(ctx CreateContext, opts CreateOptions) (*shared.IssueMetadataState, error) { var milestoneTitles []string if opts.Milestone != "" { milestoneTitles = []string{opts.Milestone} } meReplacer := shared.NewMeReplacer(ctx.Client, ctx.PRRefs.BaseRepo().RepoHost()) assignees, err := meReplacer.ReplaceSlice(opts.Assignees) if err != nil { return nil, err } state := &shared.IssueMetadataState{ Type: shared.PRMetadata, Reviewers: opts.Reviewers, Assignees: assignees, Labels: opts.Labels, ProjectTitles: opts.Projects, Milestones: milestoneTitles, Draft: opts.IsDraft, } if opts.FillVerbose || opts.Autofill || opts.FillFirst || !opts.TitleProvided || !opts.BodyProvided { err := initDefaultTitleBody(ctx, state, opts.FillFirst, opts.FillVerbose) if err != nil && (opts.FillVerbose || opts.Autofill || opts.FillFirst) { return nil, fmt.Errorf("could not compute title or body defaults: %w", err) } } return state, nil } cli/pkg/cmd/pr/create/create.go
Lines 595 to 623 in 798d903
func initDefaultTitleBody(ctx CreateContext, state *shared.IssueMetadataState, useFirstCommit bool, addBody bool) error { commits, err := ctx.GitClient.Commits(context.Background(), ctx.BaseTrackingBranch, ctx.PRRefs.UnqualifiedHeadRef()) if err != nil { return err } if len(commits) == 1 || useFirstCommit { state.Title = commits[len(commits)-1].Title state.Body = commits[len(commits)-1].Body } else { state.Title = humanize(ctx.PRRefs.UnqualifiedHeadRef()) var body strings.Builder for i := len(commits) - 1; i >= 0; i-- { fmt.Fprintf(&body, "- **%s**\n", commits[i].Title) if addBody { x := regexPattern.ReplaceAllString(commits[i].Body, " ") fmt.Fprintf(&body, "%s", x) if i > 0 { fmt.Fprintln(&body) fmt.Fprintln(&body) } } } state.Body = body.String() } return nil } Prior to
v2.75.0, the following logic blanked this information out when launch the browser for--webflag:cli/pkg/cmd/pr/create/create.go
Lines 393 to 405 in 2b89358
if opts.WebMode { if !(opts.Autofill || opts.FillFirst) { state.Title = opts.Title state.Body = opts.Body } if opts.Template != "" { state.Template = opts.Template } err = handlePush(*opts, *ctx) if err != nil { return err } openURL, err = generateCompareURL(*ctx, *state, projectsV1Support) This had the side effect of allowing the GitHub.com PR creation experience to determine the title and body using server-side information. I believe this wasn't caught by
gh pr createtests because of the local git commit state needed to be setup when going to web.Reacted by Simon Isler- Fix:
This should be fixed in
v2.75.1, thank you again for your patience! 🙇- addedpriority-1Affects a large population and inhibits workAffects a large population and inhibits workand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Jul 14, 2025 Excellent, thank you for the prompt fix!
Describe the bug
gh pr create --webnow always generates autofilled content; previously, the contents of.github/PULL_REQUEST_TEMPLATE.mdwould be populated. It looks like the behaviour now defaults to--fill, even though I don't provide that flag.Affected version
This was introduced in #10547 (fixes #10527) and released in v2.75.0.
Steps to reproduce the behavior
.github/PULL_REQUEST_TEMPLATE.mdgh pr create --webExpected vs actual behavior
Actual: the title is prefilled with the branch name, and the body is a list of commit titles.
The previous (and expected) behaviour was to leave the title empty (I think...) and have the body pre-populated with the contents of
.github/PULL_REQUEST_TEMPLATE.md.Logs
Click for logs