Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create an automatic template for pull requests in Github?

Tags:

github

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?

like image 500
AntonJ Avatar asked Jul 31 '14 14:07

AntonJ


People also ask

What is a pull request template?

Pull request templates allow your organizations to have a default text when you create a pull request on GitHub. It is quite useful to make sure to follow a standard process for every pull request and to have a to-do list for the author to check before requesting a review.

What is the difference between default pull request templates and branch specific pull request templates?

A default pull request template that is automatically applied for all new pull requests in the repository, unless overridden by a branch specific pull request template. Branch specific pull request templates that are automatically applied to pull requests targeting a specific branch.


2 Answers

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

like image 77
James van Dyke Avatar answered Sep 30 '22 08:09

James van Dyke


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.

like image 27
rjmunro Avatar answered Sep 30 '22 07:09

rjmunro