DEV Community

Leyang Yu
Leyang Yu

Posted on

Working with Others Part 2: Pull Requests

Intro

After creating the first working versions of our static site generators last week, this week was all about pull requests. I had the chance to work with Gustavo Tavares from my open source development course, who created the program GMOT-SSG.

Issue

First, I filed an issue in the GMOT-SSG repository. For this issue, I wanted to add markdown support to the program. This involved several tasks including:

  • Change file handling to accept .md (markdown) files
  • Change the file processing to detect markdown syntax for bold, italic, heading 1, heading 2, and link text and convert it to HTML
  • Update documentation to reflect these changes

Making Changes

The first step after I forked and cloned the repo was testing the program to make sure that everything was working. I noticed a few bugs, which I filed issues for here and here. After that, I reviewed the code to better understand the coding style of the author so that I could follow their style as closely as possible when adding to their code.

For the coding part, I changed the file handling so that it would accept files with either the .md or .txt file extension. In addition, I added regex to the file processing part of the program to check for markup syntax and generate the appropriate HTML if the file was a markdown file.

Pull Request

After making the changes, I created a pull request. Gustavo responded to me requesting some changes. For example, for heading 1 and 2 text, the program only tested for lines like the following: "# Heading 1", where there was a space between the markdown syntax and the text. Gustavo preferred if the program could check for zero or more whitespaces. In addition, when converted to HTML, each line of the file was wrapped in a <p> tag, including heading 1 and 2 text. However, Gustavo asked if the <p> tag could be removed for this text as it wasn't necessary. Once I made these changes, my pull request was successfully merged into the repo.

Getting My Code Reviewed

Similarly, Gustavo created an issue, added markdown support for heading 1, 2, and 3 text, updated the README, and created a pull request in my repo. I also requested some changes. For example, I requested more examples of how to use each type of markdown syntax in the README to make it easier for users to understand. In addition, Gustavo created a separate function for processing md files which was very similar to the pre-existing function for processing text files. I asked if it would be possible to combine the two to reduce repeated code. Gustavo made the changes and I also merged the pull request into my repo.

Summary

Overall, I really enjoyed this experience and it was my first time creating a pull request and getting someone else to create a pull request in my repository. I did encounter some problems, such as accidentally overriding Gustavo's changes when I made another commit in my repo. I guess there is still a lot for me to learn about open source and git but I am excited for what's in store.

Top comments (0)