DEV Community

Minh Hang Nguyen
Minh Hang Nguyen

Posted on

Collaboration and pull requests

As a part of the Open Source Development course that I'm taking, this week I needed to make some contributions to someone else's repo. As I was looking through some projects about CLI for Static Site Generator, Dustin's repo immediately caught my attention. The code is also written in Javascript but Dustin used commander, which was different from me. I thought contributing to his repo would help me learn something new so I filed an issue to add a new feature to his tool.

๐Ÿ’ปcv-ssg

Dustin's tool (cv-ssg) works smoothly and is coded in a very clean manner. He has clear logic about modules and made very good use of them. Therefore, every part of the code is easy to understand.

๐Ÿ“ŒThe new feature

Originally, the tool only converts text files (.txt) into HTML files so I suggested to add Markdown support. I proposed to first modify the validation so the tool can accept markdown file (.md) then allow the tool to parse the Heading 1 in markdown file to the correct <h1> tag in HTML format.

Coding the new feature was actually easy. This is all thanks to Dustin's existing code ๐Ÿ‘๐Ÿ‘. I could easily find where I should make the modifications since he has small modules that take care of very specific tasks. His coding style made it easy to add new feature so I only needed to add a few lines of code without modifying or removing any of his code. The testing also went through nicely as the new code does not interfere with the existing features at all. Dustin quickly reviewed the code and approved my pull request as we both agreed on the idea and the implementation earlier.

๐Ÿ“Receiving pull request

I've been sending a lot of pull requests but this was actually my first time receiving one ๐Ÿ˜„ and Dustin was my first contributor. He also proposed to add Markdown support for my tool and to parse all the headings, bold, italics and link from markdown into the corresponding HTML tags. I scanned through the pull request and found some minor issues, including missing new feature in documentation and missing the handling of the output file name. We also had different opinions about the implementation of .txt file and .md file. However after discussion, we came to agreement and I approved his changes.

๐Ÿ‘ฝFinal thoughts

Getting a pull request reviewed by others would be intimidating if we expect the result to be right or wrong. This was exactly what I felt with my very first pull request a few months ago. In fact, it is to learn a better way to code, not to judge the correctness. With the review, we can receive suggestions from more experienced coders, or from the original coders, who have more understanding about the code than us. As a "late-comer", there might be small details we're not aware of or some coding styles/rules that we're not conforming to. Reviewing is one good way to maintain the consistency of the code and to ensure that the new code has no conflict with existing one.

Top comments (0)