Tuesday, September 25, 2018

My First Pull Request to an Open Source Project

I've worked with GitHub before for private projects but have always wanted to contribute to an Open Source project. The problem was that I didn't know how to start. All these projects that I have looked at seemed way too complicated - I didn't want to spend hours learning the codebase. My problem wasn't not knowing the where to start, it was not knowing how to start. Thanks to my Open Source elective in school, I learned what to look for to get started in a larger project. I shouldn't be trying to learn the entire codebase - that would take way too long - instead, I should learn how to read smaller chunks of code in a way efficient for an issue that I would want to tackle.


What I Worked On

I contributed to an Open Source Node.js project called filer. This was a great first project to work on because of how much I learned. I wrote a [f]chmod test for Node.js's Promises module. Note that I have not coded in Node.js before, so I was a bit intimidated coming into this project. But having access to other tests helped me a lot - I didn't have to actually learn the language at a professional level to be able to contribute - I was able to see what the other tests did and mimic that style, applying it to my objective.


Trial and .catch( error )

After I studied the other test function, I began on working on the chmod and fchmod Promise tests. I quickly ran into a problem. Having to create a file, change its mode with chmod and fchmod, and then check if the mode was actually changed with stat and fstat required me to nest my function - doesn't sound too difficult but since I never used Promises. When purposly changing some values to see what it would do if it would ever fail, I found out that the way that I wrote my function did not call the done() function which signalled the end of the test. Something weird was happening, it would catch the error (I think?) but wouldn't print the error or call done() -- instead it would time out. Luckily, filer has a helpful community around it. I saw someone was having a similar issue to mine where their Promise function wouldn't hit the done() block either. Lucky for them - and me - someone commented that done() was going to be deprecated anyways and provided a different strategy to tackling the problem. Using this information, I was able to finally fix my test case and create a pull request for it in hopes of it getting merged in.


The Pull Request

I also learned about what happens after the actual coding. I had my code reviewed, and reviewed someone elses code. I used Slack to ask questions and help others with their questions. The community aspect behind working on Open Source projects is really appealing to me.

The open source method of working as a team was a really fun experience for me and I really enjoyed it. I'm excited to continue contibuting to open source projects in the future - maybe even starting one of my own.

No comments:

Post a Comment