Jamie Garner
Navigating Code and Leadership
How to Pull Request Part One
Pull Requests (PRs) are a tool used to make sure that changes to your codebase are done in a controlled manner. But how people prepare and review pull requests can be so wildly different depending where you work. So, I’ve put together a little guide about how to prepare and review them.
Set The Expectations
It’s really important to set the expectations of why you are using PRs. This will help both the reviewer and reviewee get into the right shared mind set and should include some (if not all) of the following:
- Learning opportunity
- Changes to the code are error free
- They improve the code base in some way
- Provide a quality process
- Ability to track down issues related to changes
- Help with release notes
- Make sure that the committed code meets coding standards
What is a Pull Request?
PRs are generated when you have made some change to your code base (some sort of feature or bug-fix, for example) and you are ready to tell your team what those changes are so they can review them before they get merged into the code base.
What should it contain?
Beyond addressing the issue, it should contain the following:
- A clear title that explains what it is
- A good description, where you can dive deeper into the details:
- A description of what the PR is trying to resolve and why
- Commit messages (providing they are useful, on point and don’t go off into some sort of spiral of frustration when things aren’t working)
- Any references or instructions that might be required
- The right people on the PR. Please make sure that these specific people are being added as reviewers and are in fact the right people who can approve it.
Optional Items Include:
- Link to any work items
How big should a PR be?
Always try to make your PR as small as possible (of course sometimes that’s not always possible). It’s much easier for the reviewer to check 5 PR’s that are 100 lines each rather than a massive 500 one that is split across multiple files. By making them smaller, the reviewer may thank you and you’ll often get back some useful comments.
In part two I’ll be focusing on how you review a PR