DEV Community

Alexander Samaniego
Alexander Samaniego

Posted on • Updated on

DPS909 Blog - Lab 4: Using Git Remotes and Merges

This week in my Open-Source course (DPS909), we were introduced to the concept of git remotes and merges. The purpose of this lab was to help us to practice using git remotes and merges to collaborate with our peers on some code changes.

Lab 3 was a change of pace as we worked on our own repos and did not collaborate with anyone. Now with lab 4, it's back to collaborating and adding features to other people's projects.

My Contribution

I decided to collaborate with Neil and contribute to his static site generator.

Feature Added

I wanted to add support for JSON formatted configuration files. The config file would contain all of the options that the tool supports. Instead of having users specify all of the SSG options as command line arguments, they can just specify the config file. So I created an issue and created a draft pull request so the owner can see the work I'm doing.

Code Changes

Implementing this feature was not too difficult. The main problem was to figure out a way to read and parse a JSON file and then assign those values to the appropriate option.

First, I added an additional option so that the tool will accept -c/--config flags.

I then added a conditional statement that will check if a config file path was specified. If it was, then a new function called readConfigFile will parse the JSON file if it exists. The parsed values then get passed into generateHTML to generate the appropriate HTML files.

Contribution to My Project

I had an issue that was created on my repo that wanted to add similar feature.

A draft pull request (PR) was created for this issue, so I was following every commit to make sure everything was going smoothly.

Once the PR was marked 'ready for review', I added a git remote to test the files changes locally on my machine. I didn't have much trouble working with git remotes because I had unknowingly used this feature before through Visual Studio Code's GitHub extension. The only adjustment I had to make was using the command line to create the remote instead of the GUI.

I did find one issue with the PR which had to do with error handling. I suggested adding an error message to handle non-existent config files.

This issue was swiftly addressed and fixed. I then used the git remote to test one final time before approving the changes and merging.

Conclusion

This lab went pretty smoothly. I didn't have any problems adding features to another repository or creating the PR. Most likely because I was familiar with the tech stack and language in use. I also unknowingly had experience using git remotes, so again, I had no problems with testing the PR on my repo. I just need to get more accustomed to using the command line for git remotes, instead of relying on git GUI solutions.

Oldest comments (0)