DEV Community

Uma
Uma

Posted on • Edited on

My first ever PR(Pull Request) to an open-source project experience

This article is for people who have never contributed to any open source projects but that doesn’t mean that others cannot read it though :). Doing something new always feels like a newborn baby who is overwhelmed by every small thing and doesn’t know how to react except getting fussed when something doesn’t happen and smile when something happens according to his/her desire. Every time I do something new, I am like that baby as well.

Today I am going to share my experience about how I created my first PR for an open source project called CASA.

First let's talk about what is PR(Pull Request)?

According to Github Guides : “Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red. As soon as you make a commit, you can open a pull request and start a discussion, even before the code is finished.”

You can also create pull requests to your own project and merge it on your own. It’s a best practice because in a big project that’s how work is done.

Why is it important to contribute to open source projects?

There are few important points I can share why it’s important to contribute:
To have real world working environment practice
These contributions can go on your resume as your experience which is very important, especially for fresh graduates who don’t have prior experience
To get opportunities to collaborate with senior developers and also make lots of connections
You can learn teamwork which is important when you work as a developer

Now that we have discussed what PR is and what's the importance of contribution on open source projects, let's move on to how I created my first PR. First of all, I picked the project I want to contribute to. CASA(Court Appointed Special Advocates) is a national association in the United States that supports and promotes court-appointed advocates for abused or neglected children. Then with the help of my good friend Collin Jilbert(who has been contributing to CASA for a while now) ,I got connected with a senior developer Linda(Lead of CASA team). She explained to me the whole process and added me as a contributor in the CASA project on Github. The very next day I went to their page where all the ‘issues’ were created. Here is the screenshot of the issue panel:

Alt Text

If you click on issues, you can find all the current issues casa is having in their web application, from there you can pick whichever issue you think you can solve or you can go to the ‘projects’ menu and find the ‘todo’ section where all the issues are listed. It looks something like this:

Alt Text

This way is easy because you can clearly see which issues are available, which are taken by other developers and which are already merged or completed. In progress means somebody is working on it and there is a done section as well that means it’s completed. So your focus should be on Todo.I picked something very simple since it was my first time but I was glad that at least I was starting. Once I found the issue I wanted to work on I clicked on it which pops up this box:

Alt Text

If you click on ‘Go to issue for full details’ you will see the full description of issue:

Alt Text

As you can see there are all the descriptions and screenshots of current behavior. If you scroll down on that page you can find more details and the comment section where you can ask any questions regarding issues to clarify. Now it's time to work on the issue. At this point I was super excited. I opened up my text editor and tried to set up the CASA project. Of course I had some difficulties with setting it up but as usual my friend Collin was by my side to help me to get unstuck. Lucky me!

After setting up the project on my local environment the very first thing I did was create a branch. It's highly recommended that you always create a branch before working on any project and give the branch a name which reflects the issue you are working on so that when you create a PR other developers can easily figure out what work you have done. To create branch and switch it to it I ran following command:

git checkout -b <new-branch-name>

All set to roll...
But here is the biggest challenge I faced!

Alt Text

Any guesses what it might be????

I couldn’t find the file I need to work on. This is when I saw a glance of reality. This is not a school project, where you just have 3 or 4 models, 6 or 7 controllers and limited view pages. This was the real world, where you have more than 20 models, tons of controllers and view pages and guess what? In the real world this is not even considered a big project. Phew

Although the issue I picked was small, to solve that issue I had another issue which was to find the code where issues was. After going back and forth on the description and playing around in the staging environment I finally figured out where exactly I need to work. Once I found it, it did not take long to solve the issue. I was super happy.

Things we need to be careful after solving issues are:
1.Making sure all the tests are still passing
2.Test it a few times on the site, if it’s working correctly on all screen types.

I did both and pushed it to GitHub by using following command:
git push origin <branch-you-created>

Then create a PR in GitHub like so:

Alt Text

Once you push it to GitHub you should be able to see something like this. Then click on ‘Compare & pull request’,which will bring you here:

Alt Text

Here you get change to modify branch name and add comments then click on ‘Create pull request’, which will bring you to this page:

Alt Text

But your work is done here. You are not supposed to ‘Merge pull request’ unless you are working on your own project.
Yay!
Time to celebrate. I just created my first Pull Request for the CASA project. If everything works fine someone from their team will merge it. In this case mine went everything well and it got merged. Here is the proof:

Alt Text

Now this issue is closed. :)

Overall my experience was full of fun. For ruby developers the ‘Ruby for Good’ community is a great place to be. If you would like to contribute to CASA here is the GitHub link. If you have any questions DM me or leave a comment. Finally, I just want to say to new developers, don’t wait to start contributing to open source projects. It's a better way to learn and grow.

Thank you for reading.

Top comments (0)