My experience of contributing a code change to another project.
I had never contributed to an open-source project before and doing this this first time was intimidating. It was a good way of improving my collaborative development skills, coding skills, and more importantly code understanding of a code I hadn't worked on before. I contributed a new feature to the Repository-context-packager repo-contextr which is a command line tool designed to package repository content for use with large language models. Below is how the process went:
The idea: The feature i proposed was a --recent or -f flag which will allow the CLI to only include the files modified in the last 7 days. This is useful when working with large repositories, as it helps focus on relevant and recently changed files instead of packaging the entire repository.
Implementing the feature:
At first, i encountered a lot of difficulties with this repo as the README.md instructions were not clear and the commands to run the code were not working. We scheduled a meeting online together and I showed the issues to the repo owner, as well as the commands i used to be able to run the code from my terminal.
I worked on issue-1.
The main steps included:
- Checking file timestamps: I had to do some research as I am not familiar with Python. I implemented python's os.path.getmtime() finction to be able to retrieve the last modified time of each file and compare it to the current date to determine if it was within the last 7 days.
- Integrating existing CLI options, making sure that the --recent flag works well alongside existing options like --include
- Testing the feature, by running it on its own (--recent), or combining it with other features (--recent --include "*.py").
Creating the Pull Request
Once the above were done, I committed the changes on issue-1, pushed the issue-1 branch to GitHub and created a pull request.
As mentioned earlier, it was very challenging to understand this code, and make sure the --recent feature worked correctly with the rest of the CLI options, and avoid breaking existing functionalities. I also learned how to write a clear pull request keeping it easy to understand its purpose and my feature implementation.
It was also a good experience to have a feedback from my CLI tool repository as the contributing member mentioned my README.md file was clear and easy to understand. He could follow the steps and run the code smoothly and could implement his new feature. He did not need to change many things, it was adding his new feature and updating the README.md file to reflect it. I learned about code review as it lets you have a view of your work by another person and in this way, you will easily know if you did things correctly, if everything works as expected or if you missed certain things.
Top comments (0)