Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh pr create --web prevents selection of template #7804

Copy link
Copy link

Description

@ivirshup
Issue body actions

Describe the bug

$ gh --version
gh version 2.32.1 (2023-07-24)
https://github.com/cli/cli/releases/tag/v2.32.1

If you pass --web to gh pr create you can't select a template either interactively or with the --template argument.

Steps to reproduce the behavior

I have a demo repo (https://github.com/ivirshup/gh-pr-create-web-with-template) with two pr templates:

  • .github/PULL_REQUEST_TEMPLATE/another_pr_template.md
  • .github/pull_request_template.md

Note

The bug still occurs if both templates are in the PULL_REQUEST_TEMPLATE directory.

Cloning this repo and preparing to open a pr

gh repo clone ivirshup/gh-pr-create-web-with-template
cd gh-pr-create-web-with-template

git checkout -b "a-branch"
git commit --allow-empty -m "Empty-Commit"

Opening a PR

git checkout main
git checkout -b "gh-pr-create-web-with-template"
git commit --allow-empty -m "Using gh pr create --web --template=another_pr_template.md"
gh pr create --web --template=another_pr_template.md

This creates a PR using .github/pull_request_template.md, without any warning or error.

image
git checkout main
git checkout -b "gh-pr-create-web"
git commit --allow-empty -m "Using gh pr create --web"
gh pr create --web

This creates a PR using .github/pull_request_template.md, there is no prompting to choose a different template.

image

If .github/pull_request_template.md had been put under PULL_REQUEST_TEMPLATES, I would have opened a blank PR.


git checkout main
git checkout -b "gh-pr-create"
git commit --allow-empty -m "Using gh pr create"
gh pr create

This allows selection of a template:

image

A template can also be specified correctly with --template so long as --web its not passed.

Expected vs actual behavior

I would expect gh pr create --web --template=another_pr_template.md to create a PR using the specified template.

I would have liked for gh pr create --web to have let me choose a pr template.

Logs

log
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹main›
$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹main›
$ git checkout -b "gh-pr-create"
Switched to a new branch 'gh-pr-create'
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create›
$ gh pr create
? Where should we push the 'gh-pr-create' branch? ivirshup/gh-pr-create-web-with-template

Creating pull request for gh-pr-create into main in ivirshup/gh-pr-create-web-with-template

? Title 

isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create›
$ git commit --allow-empty -m "Using gh pr create"
[gh-pr-create a08e79c] Using gh pr create
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create›
$ gh pr create      
? Where should we push the 'gh-pr-create' branch? ivirshup/gh-pr-create-web-with-template

Creating pull request for gh-pr-create into main in ivirshup/gh-pr-create-web-with-template

? Title Using gh pr create
? Choose a template another_pr_template.md
? Body <Received>
? What's next? Submit
remote: 
remote: 
To https://github.com/ivirshup/gh-pr-create-web-with-template.git
 * [new branch]      HEAD -> gh-pr-create
branch 'gh-pr-create' set up to track 'origin/gh-pr-create'.
https://github.com/ivirshup/gh-pr-create-web-with-template/pull/2
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create›
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹main›
$ git checkout -b "gh-pr-create-web"
Switched to a new branch 'gh-pr-create-web'
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create-web›
$ git commit --allow-empty -m "Using gh pr create --web"
[gh-pr-create-web 18e1819] Using gh pr create --web
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create-web›
$ gh pr create --web
? Where should we push the 'gh-pr-create-web' branch? ivirshup/gh-pr-create-web-with-template
remote: 
remote: 
To https://github.com/ivirshup/gh-pr-create-web-with-template.git
 * [new branch]      HEAD -> gh-pr-create-web
branch 'gh-pr-create-web' set up to track 'origin/gh-pr-create-web'.
Opening github.com/ivirshup/gh-pr-create-web-with-template/compare/main...gh-pr-create-web in your browser.
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create-web›
$ git checkout main
git checkout -b "gh-pr-create-web-with-template"
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
Switched to a new branch 'gh-pr-create-web-with-template'
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create-web-with-template›
$ git commit --allow-empty -m "Using gh pr create --web --template=another_pr_template.md"
[gh-pr-create-web-with-template acf6799] Using gh pr create --web --template=another_pr_template.md
isaac@Mimir:~/tmp/gh-pr-create-web-with-template ‹gh-pr-create-web-with-template›
$ gh pr create --web --template=another_pr_template.md
? Where should we push the 'gh-pr-create-web-with-template' branch? ivirshup/gh-pr-create-web-with-template
remote: 
remote: 
To https://github.com/ivirshup/gh-pr-create-web-with-template.git
 * [new branch]      HEAD -> gh-pr-create-web-with-template
branch 'gh-pr-create-web-with-template' set up to track 'origin/gh-pr-create-web-with-template'.
Opening github.com/ivirshup/gh-pr-create-web-with-template/compare/main...gh-pr-create-web-with-template in your browser.
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workinggh-prrelating to the gh pr commandrelating to the gh pr commandhelp wantedContributions welcomeContributions welcomepriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.