8000 `gh pr close` should be able to close current branch's PR without specifying PR number · Issue #11164 · cli/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
gh pr close should be able to close current branch's PR without specifying PR number #11164
Open
@Shion1305

Description

@Shion1305

Describe the feature or problem you'd like to solve

Currently, gh pr close requires explicitly specifying a PR number or URL.

As commands like gh pr create allow user to do operation without explicitly specifying the pr number, gh pr close without pr number to close pr associated with current branch should be allowed.

When working on a feature branch, developers often know they want to close "their" PR (the one associated with the current branch) but need to look up the PR number first.

# Current required usage
$ gh pr close 123
$ gh pr close https://github.com/owner/repo/pull/123

# What happens without arguments
$  gh pr close
cannot close pull request: number, url, or branch required

Usage:  gh pr close {<number> | <url> | <branch>} [flags]

Flags:
  -c, --comment string   Leave a closing comment
  -d, --delete-branch    Delete the local and remote branch after close

This is inconsistent with other PR commands that can operate on the current branch's PR automatically.

Proposed solution

Allow gh pr close to work without arguments by automatically detecting and closing the PR associated with the current branch:

$ gh pr close
✓ Closed pull request #123 (feature/new-login-flow)

Benefits:

  • Improved developer experience: Eliminates the friction of looking up PR numbers
  • Consistency: Aligns with existing commands like gh pr ready, gh pr draft, and gh pr merge that already support this pattern
  • Reduced context switching: Developers can stay in their terminal workflow without needing to check the web UI or run additional commands
  • Fewer errors: Reduces mistakes from manually typing wrong PR numbers

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussFeature changes that require discussion primarily among the GitHub CLI teamenhancementa request to improve CLIgh-prrelating to the gh pr commandneeds-triageneeds to be reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0