DEV Community

Francesco Menghi
Francesco Menghi

Posted on • Edited on

Initial Pull Requests

This week, I continued working with Git and Github to learn the basics of pull requests, code reviews and more. I collaborated with Tue Nguyen to add functionality to his Static Site Generator: tue-1st-ssg.

Making a contribution

I added support for Markdown files and sent a pull request for him to review. Luckily he liked my code and merged it into his repository.

After chatting with Tue on Slack, he suggested that I could still make improvements in the code I wrote, such as removing unnecessary "if statements". For example, for getting bold text into the tags <b></b> I wrote:

if(param.match(/\*\*([^\*]+)\*\*/)) {
  param = param.replace(/\*\*([^\*]+)\*\*/g, "<b>$1</b>")
}
Enter fullscreen mode Exit fullscreen mode

It's one of those mistakes that are more apparent for someone reviewing the code than for the person spending hours fighting with Regex on regex101.com (aka me!)

I quickly made the changes he suggested, after which I sent another pull request.

Receiving a PR

While I was working on Tue's project, he was busy adding Markdown features on my static-dodo project. He sent me a pull request and I got started reviewing it. I noticed that the program was working only with Markdown files inside a directory when that directory was selected as input like:
./static-dodo -i ./directory
but it did not work when a Markdown file was selected directly as input:
./static-dodo -i ./directory/file.md

I commented on the PR and the next day Tue had updated it and everything was ready to be merged. I am happy that my static-dodo project is slowly improving and that it has become a group effort. It was my first time receiving a Pull Request and it was a great learning experience to get more comfortable with the GitHub interface.

Doing this exercise made me appreciate the fact that writing code, especially in open source, will always be a work in progress, and that there will always be opportunities to improve and identify those sneaky bugs πŸ› along the way.

Top comments (0)