We all begin with being consumers of Open Source projects for our various different needs starting from our automation needs to building a framework which can do wonderful awesome things.
But some of us go one more step ahead and decide to give back to these wonderful open source projects that have been making our professional lives so much better. Remember, if you ever decide to take this very important step, you join the league of “extra ordinary” people who believe in giving back. So pat yourself on your back 🙂
Many of these Open source projects have their code bases hosted on GitHub [ a very popular version control system ]. We may be knowing how to go about building that new feature (or) fixing that nagging bug, but not all of us necessarily have to be knowing the nuances of how to go about delivering. This post is aimed at just walking you through on the bare minimums. As an example I am going to be taking the TestNG codebase [ I chose TestNG because that was where I started with my baby steps on Open Source contributions. I haven’t done any significant contributions, but that dream of being the top most contributor is what drives my every day. Ok enough of my boring stories.. lets get back to what we were talking about ]
So here are those steps
- Install git by following the instructions in this link.
- Setup your mail and name in git. I regard this as a very important step because it’s like your identity 🙂 Refer here on how to do it.
- Fork the TestNG repository [ This is done ONLY once ] from github. Here’s a good article that will teach you what you need to know about forking a repository in Github.
- Clone your forked repository [ This is ALSO done ONLY once ]. Here’s how to do it.
- Now from within your clone, create a new branch to represent your changes. Here’s how to do it.
- If its a new feature please make sure you have a discussion on it with the TestNG dev so that you get their buy-in/expectations etc., before you start work. Else you may end up spending time unnecessarily. Once you have a buy in, make sure you create a new issue in the TestNG repository.
- Now add your code, add javadocs, dont forget unit tests for your delivery and then also update the Changes.txt [ Every repository will have something similar to this that acts as a release notes ]
- Include a good commit message. Here’s how to do it.
- Make sure you refer to the issue that you created on github, in your commit message. This will ensure that the reviewers of your delivery will be able to tie down your delivery to the issue that its fixing. Here’s how to do it.
- Now from your clone run the command : git push origin krmahadevan-my-new-feature [ here krmahadevan-my-new-feature is the name of the new branch i create for my new testng delivery/bugfix etc., you should be replacing it with your branch name ]
- You now go about raising a pull request which is the last step of your delivery. Here’s how to do it.
Remember : From your second delivery onwards you just need to start following steps (3) to (11).
Hope that helps you with contributing to open source projects.