DEV Community

Aditya Mathur
Aditya Mathur

Posted on

Reviewing the PRs - The Perfect Way.

Introduction:

Maintaining a flawless master branch is the bedrock of a robust codebase. In the world of collaborative coding, understanding how to meticulously review pull requests on GitHub becomes imperative. Let's understand how to streamline this process and ensure the master branch remains a bastion of pristine code.

The Project Environment:

Imagine a project with a master branch where four developers toil away on their individual upstream branches. Each developer meticulously crafts their code, creating a personal branch that acts as a gateway to the master. Now, let's dive into the intricacies of the review process.

Image description

The Reviewer's Toolbox:

As the designated reviewer, your begin the process by switching to the master branch:
git checkout master
and pulling the latest changes.
git pull
Now to test the changes in a separate environment and to keep your local copy of master branch bug free and to skip the process of stashing or reverting before you merged the changes from pull request, I find making a local copy of your master branch very useful.
Let's create a local copy of your master branch where we will pull the changes from PR and that can be done by the below command:
git branch -d master_testing.

As we have already taken a pull at our master branch we can directly merge the developer's code into out testing branch.
git merge origin/[NAME OF DEV's Upstream Branch]

At any given point of time if you want to understand what needs to be done you can always check the command line instructions on PR as well:

Image description

This is where you can find all the steps you need to do in order to clone the changes of a PR:

Image description

Now, let's say at any point of time you want to request some changes that needs to be done you can always comments about what needs to be done for the developer using the Comment on this file feature:

Image description
Now let's assume I want the developer to add proper error handling in a file, that can done by raising a comment which can be seen by the developer on the PR page

Image description
Once you have added your comment you can submit the review with general feedback

Image description

which can we be seen on the conversation page like below

Image description

Once the developer has added the error handling as per your comment he can just push to the upstream branch and you can review the changes and resolve the conversation and you are all set.

Image description

Now you can successfully merge the pull request with your master branch.

And there you have it a PR reviewed and merged with your master branch without hampering your local master branch.

The below image would be useful to visualize the process that we followed.

Image description

The interaction culminates in the GitHub UI, where comments become the canvas for collaboration. Any changes, suggestions, or concerns find their place in this digital dialogue. It's a seamless way to iterate, ensuring the final code aligns with the project's standards.

Conclusion:

Mastering the art of pull request reviews on GitHub is not just a technicality; it's a testament to collaborative coding excellence. By creating a robust workflow — from pulling the latest changes to leveraging git stash for refinement — the reviewer becomes the guardian of a pristine master branch. With these tools in hand, the development journey becomes not just efficient but a testament to the power of collaborative coding.

Thank you for reading! If you have any questions or feedback about this article, please don't hesitate to leave a comment. I'm always looking to improve and would love to hear from you.

Also, if you enjoyed this content and would like to stay updated on future posts, feel free to connect with me on LinkedIn or X or check out my Github profile. I'll be sharing more tips and tricks on Django and other technologies, so don't miss out!

If you find my content valuable and would like to support me, you can also buy me a coffee. Your support helps me continue creating helpful and insightful content. Thank you!

Top comments (0)