How I made my first contribution to open source software
I was brushing up my Android skills by following Google’s Android Basics with Compose course, when I noticed that a file was missing from the solution code’s repository. The associated codelab was called “Write unit tests to test the ViewModel”.
Fortunately Google allows us to propose changes through GitHub’s pull request feature. And that’s exactly what I did. Let’s break down the steps:
1 — Post an Issue
Before we solve the problem, let’s clearly define it by posting an Issue on the GitHub repository. In this case, someone had already done that for me:
By the way, I’m assuming you have basic Git and GitHub knowledge.
2 — Fork the repository
We can’t push changes directly to the repository. Instead, we have to fork it and submit a pull request from the fork, targeting the main repository.
3 — Make the changes on the forked repository
- Clone the forked repository onto our local machine
- Create a new branch to house the changes
- In this case, a bit of digging in the Git history using Android Studio revealed that
GameViewModelTest.kt
was accidentally removed in a previous commit. - Also using Android Studio, I was able to revert that particular change in the commit and restore the file. JetBrains products are pretty convenient!
4 — Follow the instructions on contributing.md
This file tells you how to become a contributor and submit your own code. Google won’t even look at your changes otherwise. In this case, I had to fill out the individual Contributor License Agreement (CLA).
5 — Open a pull request
Issue? Check. Changes? Check. CLA? Check.
We open a pull request so the maintainer at Google can take a look at our proposed changes:
6 — Wait for maintainer to respond
This time I had the best case scenario — the maintainer at Google reviewed my changes the next day, approved, and merged. In other cases, it might take a while for the maintainer to respond, or they may leave comments on the pull request for us to address before merging.
And that’s my first contribution to open source!
What is open source software?
Open source software is software with source code that anyone can inspect, modify, and enhance.
What are the benefits to contributing to open source software?
- You can improve the software you use
- You can meet people with similar interests
- You can build a reputation and career by contributing to interesting products
- You can learn to work as a team
How can I start contributing to open source software too?
Note the first benefit of contributing to open source software:
Improving the software you use
Rather than thinking about contributing to open source, you should instead think of it like:
- I want to improve a product that I use already
- I wish X product had Y feature
I think it’s super misleading when someone tells you to “just contribute to open source.” You can’t just waltz into someone’s codebase and expect to understand anything that’s going on, especially if you don’t even use it.
In my case, I noticed that there was a discrepancy in the documentation of the codelab repository. All I did was restore the file — that’s still an open source contribution! You can probably do something very similar in another project you use frequently.
Conclusion
Contributing to open source is very daunting. It really feels like one of those “10x developer” activities. However, I hope this article helps point you in the right direction, and you’ll remember my words the next time someone tells you to “just contribute to open source.”