ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
796 stars 68 forks source link

Pull request template #266

Closed rvi closed 1 year ago

rvi commented 2 years ago

Hey @ejoffe, I wanted to have your feedback on this feature? I think a lot of users are using PR template, it would be great to be able to use them as well. Let me know happy to give it a try!

Cheers,

Discussed in https://github.com/ejoffe/spr/discussions/263

Originally posted by **rvi** August 12, 2022 Hi, I love this tool but unfortunately it doesn't take into account when there is a [pull request template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository). I'd love to be able to have `pullRequestTemplatePath: "path/to/pull-request-template.md"` in `.spr.yml` and inject the commit message in it. For instance we could look for a variable like `%%COMMIT_MESSAGE%%` in the PR template and replace it. If we don't find this variable we could append the commit message at the end or the beginning of the template. I can try to develop it but I'd like to know first if you're onboard with this idea. Let me know what you think! Cheers.
ejoffe commented 2 years ago

This sounds cool! I have never used pull requests templates. Can you describe with more detail how you think of integrating spr with this, from the little reading I did, it looks like this is mostly used when creating pull requests using the ui. But I guess there must be a nice way to render the template and then use the api?

rvi commented 2 years ago

Sounds good, I'll try to have something this week!

danielcompton commented 2 years ago

The gh CLI also uses PR templates. By default when opening a PR with one commit, it:

  1. Creates a temp file copied from .github/pull_request_template.md
  2. Adds the body of the commit message to the top of the file
  3. Opens the temp file in $EDITOR, leaving the user to complete the PR body and save the file on quit.

You can see it in action with gh pr create.

dan-v commented 1 year ago

@ejoffe - I'd like to contribute a PR for pull request template support, but wanted to run my current thoughts by you on implementation. My current idea that I have working adds the following repo settings:

For example if you had a template like below you'd set the following settings and it would insert the generated body below the Description heading on PR create/update.

Description

# Checklist [ ] A checklist item ``` On PR update, it would actually just read the existing PR body which should have the template from the initial PR create and just insert the updated body in the same way. This would allow not having to set `preserveTitleAndBody` to true as you'd get to keep all your PR template in place on updates and only update that body insert section.
ejoffe commented 1 year ago

Looks good to me. Lets give it a try.