This is another contribution I did as part of my OSD600 course at Seneca College. This would be one of my final ones, as other assignments catching up to me. But I really liked that I was able to contribute to many interesting projects as part of this assignment.
This time, I contributed to Magika, a tool by Google to detect file content types using machine learning. It seemed like a pretty cool project and I thought I might be able to use it for my open source project RefactorCode which surprise-surprise refactors your code.
The issue was to update the github actions workflow to check that their README (for the python package) doesn't contain relative paths. I first reached out to the issue author with a couple of questions, and he quickly clarified them.
So I forked the repository, created a new branch, and opened a draft pull request. I added a new function that parses the markdown for links. I used regex for this. There is also regex validation to check if the links are relative. It then uses the requests
module to check if the links are valid or not. If a link is invalid, it is added to an error list so the program finds all errors in one run instead of stopping at the first one. It then prints out information about each error.
The goal was to prevent the package from building if the documentation contains links that users can't access. It took me a bit of time to get the regex working, but with some help from Stack Overflow, I figured it out.
Once I was ready, I converted the draft to an actual pull request and waited for feedback from the issue author. I received some great constructive feedback early on. The code did not pass the ruff format check, so I had to update the code to the correct format. There was also a suggestion to make the function more generic to Markdown. So I updated the code for it. I also made it work for folders but based on the suggestions from the author that it made it overcomplicated, I reverted it for only one markdown file path.
I tested it in a modified README to see if it worked, and it worked great!
After a series of feedbacks and updates, the code met all requirements and was successfully merged into the main branch. There was a lot more communication and feedback compared to my previous contribution, and I learned a lot about how to communicate asynchronously.
Overall this whole series of contributions was a really fun,
It made me better to understand code bases with different styles and format, how to contribute to open source effectively. I gained a huge amount of appreciation for the countless contributors across various repos who have spent their time and effort, sharing code freely for everyone.
I look forward to being a part of this community in the future and continuing to give back.
Top comments (0)