Skip to content

Support completion for gh pr create --base option #5576

Description

@zyf0330

Describe the feature or problem you’d like to solve

I must type branch which PR will be merged into manually.

Proposed solution

I hope gh completion supports gh pr create --base ${branch}

Additional context

Add any other context like screenshots or mockups are helpful, if applicable.

Activity

  1. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed on May 9, 2022
  2. mislav commented on May 25, 2022

    @mislav
    Contributor

    We like this idea! More branch flags across other commands could also get the same treatment. Namely:

    • browse --branch
    • codespace create --branch
    • pr create --base
    • pr create --head
    • pr edit --base
    • pr list --base
    • pr list --head
    • release create --target
    • release edit --target
    • repo sync --branch
    • repo view --branch
    • run list --branch
    • workflow run --ref
    • workflow view --ref

    To enable completion, RegisterFlagCompletionFunc could be used. To anyone who wants to contribute this feature: see existing usages for examples.

    Inside the completion func, the logic could be:

    • Check if --repo flag override was used, and bail out if it has. There is no sense of querying the local git repo in this case;
    • Shell out to git branch --remotes and collect all rows;
    • Strip the remote/ prefix from all rows;
    • Sort and de-duplicate results;
    • Return the results as completion options.
  3. added and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on May 25, 2022
  4. changed the title [-]Support completion for gh pr create --base option[/-] [+]Support completion for `gh pr create --base` option[/+] on Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions