DEV Community

mpa-LHutchinson
mpa-LHutchinson

Posted on

Week 3: Lab 2 pull request

Introduction

This week, I worked on both finishing my release 0.1 and finishing lab 2, which involved partnering with another student and working on their code to add a new feature. In this blog, I will go over the process of expanding on another persons code, and how I took advantage of git to make this process safer and easier.

Creating an issue and a new branch

First, I needed to create a new issue on my partners repo, detailing the new feature that needed to be implemented, which can be found Here. This new feature is the --token (or -t) command, which will display some information about the token usage after a successful response from the AI. Next, I needed to fork their repo. Luckily, I already did this for last weeks lab so I could move on to cloning this project on my local machine. Now, I needed to create a new branch to work on, so any changes I make won't effect the main branch until the pull request is later approved.

The code

Now I needed to implement the new feature. Since we worked with GROQ, I first needed to find some documentation online about how to get the token information. I found it Here, and I was able to learn the schema for gathering token information. Then, I looked over my partners code and copied parts of it for the new feature, modifying it to fit. This way I could add the new feature while keeping the style of code my partner wrote in tact. After testing a couple of times to make sure the new feature works, I updated the README document to include the new command in its list. Overall it was a nice and simple feature to implement, since both of our projects accomplished a similar task.

Pull request and merging

Finally, once I made the changes, I pushed them onto the new branch and created a pull request, which can be seen Here. My lab partner approved the changes and merged the branch with his own main branch, so now the feature is implemented. He also added the same feature to my own code, so now I am able to view the token information of my program. Overall this exercise was a fun, simple experience that helped the both of us get more experience with separate branches and pull requests.

Top comments (0)