Skip to content

gh pr create Add option to use first commit as PR title/description #7239

Description

@billyvg

Describe the feature or problem you’d like to solve

gh pr create --fill has a good default if you only have a single commit: it creates a PR with the commit's details as title/description. However I generally write my first commit's message knowing that it will be used as the PR title/desc and will have follow-up commits that I expect will be squashed at some point. When using gh pr create --fill when there are multiple commits, it uses the branch name as PR title and the list of git commit titles as the PR description.

Proposed solution

Add a CLI option that will always fill the PR title/description using only the first commit's message. This won't disrupt the default and helps support a different and reasonable workflow.

Activity

  1. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed on Mar 28, 2023
  2. vilmibm commented on Mar 28, 2023

    @vilmibm
    Contributor

    Since --fill is used from scripts, this would be a breaking change. marking for discussion in our next sync.

  3. billyvg commented on Mar 28, 2023

    @billyvg
    Author

    Since --fill is used from scripts, this would be a breaking change. marking for discussion in our next sync.

    What if the option accepted an arg, or if it were a new option, in order to avoid a breaking change?

  4. mislav commented on Apr 19, 2023

    @mislav
    Contributor

    We discussed this and we're open to gh pr create --fill-first, a new flag. We definitely want to keep backwards compatibility with --fill, which was designed to emulate the web behavior of creating a PR.

    People who want to help us implement this can start here:

    if opts.Autofill || !opts.TitleProvided || !opts.BodyProvided {
    err := initDefaultTitleBody(ctx, state)

  5. kousikmitra commented on Apr 20, 2023

    @kousikmitra
    Contributor

    If gh pr create --fill-first is finalized I can take this up.

    Expectation:

    • --fill-first flag to be added
      - --fill and --fill-first both cant be used together
    • If --fill-first is used then
      - In case there's only one commit, title should be filled from commit message and body to be filled from commit description (same as current --fill behaviour)
      - In case there are multiple commits, First commit message should be used as title and all commit message should go in PR body

    Please let me know if I am missing out anything.

  6. litzy29186 commented on Apr 22, 2023

    @litzy29186
  7. mislav commented on Apr 23, 2023

    @mislav
    Contributor

    @kousikmitra: that sounds almost correct, just a clarification: if --fill-first is used, there is no difference in behavior when a PR has 1 commit or more than 1 commit. In both cases, the subject of the first commit becomes PR title, and the description of the first commit becomes PR body.

  8. kousikmitra commented on Apr 23, 2023

    @kousikmitra
    Contributor

    Got it. Will raise a PR soon.

  9. natebrunette commented on May 23, 2023

    @natebrunette

    It would be nice if you could specific a commit and have it default to HEAD

  10. kousikmitra commented on May 31, 2023

    @kousikmitra
    Contributor

    It would be nice if you could specific a commit and have it default to HEAD

    It doesn't default to HEAD but the first commit of the difference HEAD...{default branch}.
    We can have an option to specify a commit to use but I personally don't see any reason to have that option.

  11. natebrunette commented on May 31, 2023

    @natebrunette

    For example, I might do the main work first and then do some other refactoring work that I want to keep separate as additional work afterwards (spacing changes, rearranging lists, etc). I'd like to be able to specify the first commit I did for the --fill. In different cases I might reverse the order.

  12. added and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Jun 19, 2023
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 CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions