Reputation: 519
I want to create a template that will appear automatically on each pull request.
This can either be a note or a comment. Ideally it will display guidelines as to reviewing the pull request:
- [ ] Have you done x?
- [ ] Have you done y?
- [ ] Have you done z?
Can anyone suggest a way of doing this?
Upvotes: 18
Views: 10293
Reputation: 28096
GitHub does not allow you to create a template for pull requests created on it's website.
The solution we use is to create pull requests using the github api via the hub
command. We wrap this in a script called makePR that does something like:
#!/bin/bash
URL=$(hub pull-request -F PR-template.md)
echo "New PR created at $URL"
open $URL
(untested - our actual script does a lot more - I've left out parameters I think you don't need)
The open
command will open the URL in the default browser on MacOS, you may need to adjust this for other platforms. Once it is open, you can edit the title in your web browser.
Upvotes: 4
Reputation: 19573
Unfortunately, this is not possible with GitHub alone. Good news, GitHub now supports this! Check out the accepted answer.
Also, GitHub has a pretty cool (and somewhat hidden) feature that you can use to link potential contributors to some contribution information whenever they create a new issue or pull request.
From Contributing Guidelines on The Github Blog:
We've tried making this easy for everyone. As a maintainer, all you have to do is add a CONTRIBUTING file (or CONTRIBUTING.md if you're using Markdown) to the root of your repository. Then we will add a link to your file when a contributor creates an Issue or opens a Pull Request.
Now, as soon as your collaborators start participating, they can easily find the guidelines you'd like them to follow.
Upvotes: 2
Reputation: 33
Right now it is possible to create templates for issues and pull requests. It can be described in the ISSUE_TEMPLATE
, or PULL_REQUEST_TEMPLATE
files in the repository root or in the .github
folder.
You can find more information here https://github.com/blog/2111-issue-and-pull-request-templates
Upvotes: 0
Reputation: 6871
GitHub now support pull request template through PULL_REQUEST_TEMPLATE.md
file
https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/
Upvotes: 4
Reputation: 5080
Yes, it is now possible.
Add a file named pull_request_template.md
to the root of your project:
- [ ] Have you done x?
- [ ] Have you done y?
- [ ] Have you done z?
You can also create a template for issues using the same convention. Just name the file issue_template.md
.
Source: https://github.com/blog/2111-issue-and-pull-request-templates
Upvotes: 17
Reputation: 28096
There is a chrome extension that claims to do it here: https://github.com/sprintly/pull-request-template-chrome-extension
Unfortunately, I couldn't get it to work, but the code looks simple enough to figure out and fix - I expect it's something simple that has broken due to github or chrome being updated.
It only seems to allow you to use a single template for every github pull request that you make, rather than pull in the correct template for the current repository.
Upvotes: 1