It was a normal working day, I was about to review an important PR when Bitbucket went down. It was the genesis moment for this thought 🤔
What happens to the PR review cycle in a non-GitHub world?
After a few minutes, Bitbucket was up and running, but the thought was still alive. I did some research + thinking and came to the following steps that one can follow if something urgent comes up!
Checkout to the branch you want to review, Assume the feature branch is named as feature-branch
.
On this branch, execute:
git checkout -b review-branch
As the review-branch
is based on feature-branch
it will have everything that we need to review.
You all must be aware of git diff, it is used to compare two branches. Execute the following with the branch, you want to compare it with.
git diff base-branch review-branch
Note: The
base-branch
can be master/main or devel, depending on your project structure.
The diffed output with git added/removed lines notation will be thrown on the terminal. It may or may not be user-friendly 💀. Skim through the changed files, select a suitable line above the change where you want to add the review comment. Type the following:
// Review-comment - Hey please change 1+1 = 3 to 1+1 = 2, thanks!
Add, commit, and push the review changes in a fixed format with an identifier (for eg Review-comment) and handover the branch to the reviewee.
The git grep
is pretty interesting and powerful, and I hope you would have guessed its usage here.
Reviewee just has to grep the review comment identifier to get the list of all the review comments.
git grep 'Review-comment'
From here onwards, the changes can be pushed to the review-branch
. Then we can merge the review-branch
into the feature-branch
and
get that merged further into the base-branch
.
There may exist numerous other ways to do the review cycle without git management systems. This is just what I thought of as a possible solution. If you can think of other ways, do let me know! Also, writing this blog made me realize how important these git management systems are 🚀.
Thanks and happy reviewing!