Do you find writing pull requests hard? It shouldn’t be. But writing a great pull request, whether in Git or in Jira using Bitband’s Git-Jira plugin) still seems like a fine art when teams are trying to write clean code. The issue, it seems, is that sometimes it’s tough to be concise, and pull requests are best when they are short, descriptive, and do just one thing (not 20!).
A reasonable pull request can be reviewed quickly, reduce bugs getting introduced into the codebase, and does not block other devs while also making it easy for new devs to onboard.
If you’re looking for ways to nail your pull requests, read on for some great tips you can initiate immediately.
5 Pull request Tips to Master
Write Well
Code, like any other kind of writing, needs to follow the rules. If your spelling or grammar is off in regular writing, the sentence itself may not make sense. The same is true with code. Break the rules, and you likely will see runtime fails. When you’re writing code comets, pull requests, or commit messages, make sure your spelling in grammar makes sense. After all, people need to read the final result, and writing well will make reviewing go faster.
Don’t Do Multiple Things
If you are trying to write a pull request for two or more different things, you run the risk of the reviewer agreeing with only part of your request, but not all of it. If you instead have a hard and fast rule of only dealing with one thing at a time, your request can get dealt with on time and merge into the master quickly.
Make Your Pull Request Small
If you’ve already followed the above rule of not doubling or tripling up on issues in a single pull request, you are already on your way to making the request you are working on as small as possible. Remember that someone needs to review your pull request, and making it lengthy makes the review process take longer. On top of that, a long pull request may cause the reviewer to “re-prioritize” reviewing it, and they may set it aside until they have the required chunk of time to dig in. The bottom line: if you want your pull request removed sooner rather than later, make it as small as possible for easy review.
Keep Your Lines Under 80 Characters
This isn’t a hard rule. However, if you are trying to save the sanity of your reviewer (see above), consider how they are likely to review that pull request of yours. Likely, they’ll check using a diff tool (with a browser-based diff view), meaning they’ll run it side-by-side, meaning they’ll only have half a screen to see the pull request. If your lines are shorter, they won’t have to scroll across. They’ll be able to easily read it on their half-screen, meaning your code will be much easier for them to review.
Make Sure Your Pull Request Works
It seems like a no-brainer, but we’ll put it out there anyway: before submitting any pull request, build it on your own machine and see what happens. It’s literally the absolute minimum you could do.
Bonus Points for Documentation
Consider documenting the why behind how you wrote the code (not what the code does or is meant to do). If you need to, add a code comment so that the comment is located with the code (this way, you can preserve the comment even if the code changes). You can also add comments in commit messages, and here you can lay out why you do things in a specific order. At least, if you do this, the reviewer can see your general line of thought and can review faster based on that. It will also preserve your line of reasoning for other team members, and maybe even yourself if you return to it after a length of time.
Conclusion
By keeping things short and sweet in pull requests, you’re able to get your code past the review stage quicker. You’ll also be writing cleaner code – and more of it – as you learn more ways to be concise in the way you work.
Do you work with Git and Jira and wish they could communicate together? We’ve got an app for that! Try our apps for GitHub, Git, GitLab, Bitbucket, and Beanstalk – all of which allow for easy integration with Jira! Check out our full list of Jira-Git integration apps on the Atlassian Marketplace.
Want more Bitband insights? Check out: