DEV Community

Harshil Patel
Harshil Patel

Posted on

Learning Git Fetch, Pull and Remotes While Adding a Feature to Open Source Project.

This week, we were learning about Git merge and remotes in our open-source course at Seneca. The learning wasn't just about watching videos; we were also tasked with utilizing Git features by implementing a feature in one of my classmate's repositories while someone else added the same feature to mine. My task was to test and merge this feature.

We were tasked with implementing support for TOML configuration files. Since I wasn't familiar with TOML, I researched it and discovered that TOML (Tom’s Obvious, Minimal Language) is a straightforward, human-readable file format designed for defining key-value pairs. For this task, I was looking for a repository to work on and found codeshift, a command-line tool that translates source code files into a chosen programming language. I opened an issue for adding this feature and informed the owner that I was going to work on that issue.

Contribution

First, I forked and cloned the codeshift repository and started getting familiar with the file structure. After that, I went through the README file and tried to run the CLI tool locally. Then, I started exploring different JavaScript/npm packages I could use for parsing the TOML config file. I found a popular package, smol-toml, and decided to use this to add the feature. I installed the package and added the feature to utilize TOML config. However, I misread the instructions, and as a result, the code was looking for a .codeshift.toml config file in the project’s root directory instead of looking in the user's home directory. I pushed the code and opened a draft PR, and once I completed all tasks, I changed the status of the PR from draft to ready for review.

The owner pointed out my mistake and asked me to update the code to look in the user’s home directory for the config file instead of the project’s root directory. I updated the code to resolve the error and pushed the changes. Finally, my PR got merged, and the owner closed the issue.

In addition, Aryan was working on my repository to add the same feature, but my role for this PR was as a maintainer. Once I received the PR, I used various Git commands like add remote and fetch to pull the PR changes to my local machine so that I could test the code before merging it. Although the code changes looked correct when I checked them on GitHub, I got an error when I tried to run the code locally. The error was tomllib module not found. I checked the requirements.txt file and found that the tomli package was missing. Therefore, I added a comment on the PR requesting the package be added to requirements.txt. Once this was fixed, I fetched the code from the remote issue branch again and retested it. It worked as expected this time, and I merged the issue branch to the origin/main branch.

Conclusion

The concepts I learned this week will definitely help me in my open-source journey. To be honest, I tried learning all these things before, but I got overwhelmed and dropped it in the middle. I am thankful to our professor for teaching these Git concepts. I am now planning to start contributing by solving actual bugs in other open-source projects, and I feel confident with Git for doing so.


This version has corrected grammar, punctuation, and structure.

Top comments (0)