Skip to content

Prepend commit bodies in gh pr create with templates #1570

Closed

Description

@dhleong

Describe the feature or problem you’d like to solve

Currently, if a PR template exists in the project, that's all that goes into file when hitting e to "edit" the PR body. It'd be convenient if we could pull in commit bodies, since—especially for single-commit PRs—those bodies already have the explanation we would otherwise want to include in the PR. There is prior art in that I believe in the absence of a template, gh already does this as the only content. Furthermore, I believe that github's web interface will prepend a single-commit body to templates.

Proposed solution

Perhaps a flag like --prepend-commits-to-templates and/or --append-commits-to-templates? Or something less verbose.

Additional context

My company uses a PR template as a checklist. I've been enjoying using gh pr create with this, since Vim makes filling out the checklist very easy. However, if I want to include the commit body as context, it's quite a bit of extra work to grab that and include it.

Activity

  1. added
    enhancement
    on Aug 24, 2020
  2. mislav commented on Aug 26, 2020

    @mislav
    Contributor

    Thank you for the suggestion! I definitely agree that we should act more like GitHub.com web interface when it comes to templates.

  3. utkarsh-khandelwal12 commented on Aug 28, 2020

    @utkarsh-khandelwal12

    Hi
    I have just started working with PR Templates and I do feel like this is a nice enhancement.
    @mislav I would like to work on it.

  4. dhleong commented on Aug 28, 2020

    @dhleong
    ContributorAuthor

    I can confirm just now that a single-commit PR created on Github web prepends the commit body to the template. Having even just this behavior by default would be super convenient :)

  5. utkarsh-khandelwal12 commented on Aug 31, 2020

    @utkarsh-khandelwal12

    @mislav I would like to get an update

  6. vilmibm commented on Sep 1, 2020

    @vilmibm
    Contributor

    hi @utkarsh-khandelwal12 , it looks like @dhleong has already started working on it.

    I'm happy to take a community PR for this so it's up to the two of you who continues work on it.

    This behavior makes sense to me as a default and I don't think a new flag is needed; thus, I think the next step is to just add test coverage to #1611 ?

  7. dhleong commented on Sep 2, 2020

    @dhleong
    ContributorAuthor

    Hey sorry didn't mean to step on anyone's toes, I just keep running into this issue!

    I've added a quick test that verifies the behavior of including the "default" commit message, prepended in front of any selected template body. It took me a bit to try to understand how the existing tests work, but I think it follows all the existing conventions. Please let me know if you want tests for other cases.

  8. mislav commented on Sep 10, 2020

    @mislav
    Contributor

    @dhleong Thank you for your contribution! Is there any functionality still missing or incomplete now that your PR has been merged?

  9. dhleong commented on Sep 10, 2020

    @dhleong
    ContributorAuthor

    Nope, I think it's best to keep it simple as-is. Thanks!

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions