DEV Community

Cover image for A different way of reviewing pull requests
Luke Nguyen
Luke Nguyen

Posted on

A different way of reviewing pull requests

Introduction

When collaborating on an open-source project, you would often see beginners like myself relying on the GitHub website to review pull requests. However, the process was cumbersome, and I often wish there was a different way to see my partner's work and merge their pull requests without leaving the text editor. Luckily, Git does have a concept called Git Remotes, and in this blog, I will walk everyone through my journey of learning and using it.

Adding support for a new feature

After looking through my classmates' projects, I decided to work on Minh Hang's static site generator and filed an issue to her repo.

The objective was to add support for config files through the -c or --config flag. As both of us were using yargs to build the CLI, I could add a new argument by using the option() method:

.option("config", {
    alias: "c",
    describe: "Specify config file",
    type: "array",
}
Enter fullscreen mode Exit fullscreen mode

Additionally, I added an "if" statement to make sure that the tool will discard all other options when -c or --c is specified:

if (argv.config) {
  const configPath = argv.config.join(" ");
  processJSONFile(configPath);
  return;
}
Enter fullscreen mode Exit fullscreen mode

Reviewing and testing my partner's work with git remote

To my understanding, a Git remote repository allows us to have a copy of the code on our local machine, and we can experiment on it without worry about affecting the original. Additionally, we can also get updates when there are changes by fetching.

With that in mind, I began adding Hang's code as a remote to my local repo, carefully making sure that I'm not merging anything unnecessary by using git fetch instead of git pull:

git remote add minhhang107 https://github.com/minhhang107/mini-ssg/tree/issue-12
git fetch minhhang107
Enter fullscreen mode Exit fullscreen mode

I then created a new branch to track any additional commits, referencing the issue-12 branch from my partner's fork:

git checkout -b minhhang107-issue-12 minhhang107/issue-12
Enter fullscreen mode Exit fullscreen mode

After setting up the remote branch, I began testing the implementation with the sample files/folder I made and providing feedback to my partner via Slack. With any additional changes/commits, I kept fetching them to the remote branch and continued testing until I could merge the working code to my main branch.

Conclusion

Git Remote is a handy feature that makes it easy for many developers to work on the same project. However, getting familiar with the command and understanding when to use them is quite a steep learning curve, as I often find myself going back to Git's documentation or my course's lecture. Hopefully, with enough practice, I can be more comfortable with using them.

Happy coding! 💻

Cover image by Roman Synkevych on Unsplash

Discussion (0)