One of the greatest thrills of working in Open Source is receiving your first pull request. Learning that someone not only took an interest in your project, but took enough interest to fork the code, make a change, and then submit it as a pull request is such an incredible feeling. Receiving pull requests is amazingly fun at first but, as the number of pull requests pile up, it can quickly grow overwhelming.
I have reviewed quite a few pull requests in my time at Chef (and outside of Chef as well). This is my current activity distribution on GitHub – as you can see, pull request reviews make up a significant portion of it.
Over the years of reviewing hundreds of pull requests, I have found there are four key duties anyone who reviews a pull request must fulfill.
Let’s go into these in depth.
One of the worst things to experience as a contributor is to open a pull request and have it just sit open with no response for months or years on end. When someone opens a pull request on a project you maintain, you must respond, even if it is to say “no” (more on how to do that shortly). Saying “I don’t want to respond because I don’t want to say no and hurt their feelings” is not acceptable. It hurts the contributor more to not hear anything and see the pull request just hang there. It hurts them less to be told no, given a reason why, and seeing the pull request closed.
When you have LOTS of pull requests to review (when I became the lead on Habitat Core Plans there were 85 open pull requests on the repository) it’s crucial to quickly assess whether a pull request adds value to a project. Asking a few key questions will help determine this:
The ultimate thing to remember for DevSecOps is that pull requests return negative value when they make contributions from current and future contributors harder. There are sometimes good reasons for this, but it’s crucial to weigh the risk of merging a pull request that will cause more difficulty in contribution, even if it is the superior approach from a purely technical standpoint. Open Source projects live and die by community engagement.
When the pull request does indeed add value, there are a few more key questions to help evaluate the code.
When the answer to each of these questions is yes, that usually means the pull request should be approved. Again, if the whitespace or style decisions do not violate a linter or style guide, please just leave them alone. It can seem fun to fight about, it can seem fun to be pedantic, but that will discourage someone from contributing to the project. It is not a good experience to open a pull request that fulfills all requirements and see it rejected purely based on differing opinions of whitespace or other styling.
Again, it is absolutely crucial to respond to all pull requests, especially when it is something that ultimately cannot be merged. It is critical to communicate in a way that is supportive both of the contributor and their work. Do not trash their work – even if it’s something they really should have thought more about or talked to a maintainer about first.
A common question I hear is “What do I do if I give feedback on a pull request and the person who opened it does not respond?” If you give someone feedback and they don’t respond in a week or two, it is fine to close the pull request. I close these pull requests with a comment – “If you are able to address the feedback in the future please feel free to re-open the pull request, but I am closing it for now”. If the person responds but your re-review and delay will be delayed, mention it in a comment on the pull request and set an expectation on when you will be able to review it. Most people are much more understanding of this than you would expect.
For an Open Source project to not only survive but thrive, it must have a cultivated community of contributors. Again, Open Source projects live and die by community engagement. Much of your interaction with contributors will be through GitHub issues and pull requests – it is crucial to handle every interaction with care. It may seem hard at first, but the rewards are immense. It is a wonder to see how people use a project, enhance it, and change it into something I never imagined. Treating your contributors with care and support is not only the right thing to do, it will enhance your project’s viability, sustainability, and overall impact on the world.