DEV Community

Katie Liu
Katie Liu

Posted on

1

My first Open Source contribution!

This week I made code contribution to my classmate Yumei's GitHub repo, ConvertTxtToHtml. ConvertTxtToHtml is written in Java and is a command-line program which converts .txt files to .html. I added a two new features to the program:

  • to allow .md files as input in addition to .txt files
  • to convert md syntax links to html syntax links

Here is the process I went through to make my contribution:

1) First I filed an issue on her main project GitHub. This allowed her to give me feedback on how she would like me to handle the issue.

2) Next I forked the project on GitHub, and cloned my fork. I created a branch for my work and named it issue-7 after the issue I filed earlier.

3) On my local machine, I tested the existing program to make sure there were no bugs. I read the code thoroughly to understand how it worked, and to familiarize myself with her coding style and formatting style. Then I added my new features, taking care to make as little change to the existing program as possible. To do this, I created private helper functions to separate my code, and then called those functions in a few locations in her existing code. I also added comments, and updated the existing README file to include my changes. After testing my changes and adding a test file to her folder of test files, I pushed the changes to my branch.

4) I created a Pull Request in her main project repo and submitted my branch. I described what changes I made and asked for her review and her feedback on any changes she required.

5) Yumei commented on my pull request with changes she wanted me to make:

  • fix a bug where [someText][linkText](http://linkgoeshere) would display someText as a link rather than linkText
  • make link conversion only occur for .md files (not .txt files)

6) I fixed the issues she brought up, and pushed the changes to my branch. I then replied to her comment that each item was fixed.

7) Yumei commented that my changes looked good and merged my Pull Request. Since I used the keyword "Closes #7" in my pull request, the issue I raised was automatically closed.


Initially I had some problem trying to figure out the best way to convert links from md to html. I did some research online and decided to use regular expressions. I did a lot of testing with the Pattern and Matcher classes so that I understood how to use regex to identify patterns in a string. Then I wrote my private helper function which converted links from md to html.

Aside from learning how to use regex to parse strings in Java, I also learned to do more thorough testing. Yumei found a bug which I could have caught myself if I had tested with more edge cases. Next time I make a contribution, I will create a series of test input files to test multiple edge cases and document my testing in a file so that I ensure I test all the scenarios.


Yumei also contributed to my Open Source application, which was a similar program, go-go-web, but written in Python. She raised an issue and submitted a Pull Request to my repo. Here are the steps I took to review and merge her pull request.

1) Read the details of her Pull Request. It include the following features:

  • support for .md files
  • converting md syntax bold and italics text to html syntax bold and italics text
  • changes to version file and README file

2) I cloned her branch to my local so that I could review the code. I used the following command:

git clone --single-branch --branch <branchname> <remote-repo>
Enter fullscreen mode Exit fullscreen mode

3) I read and tested her code. I found a bug, which I took screenshots of and asked her to fix in a comment to her Pull Request. The bug was that the italics conversion was erasing a space. I also asked her to add a test file that tests both the bold and italics conversion.

4) She fixed the issues I mentioned and I merged the Pull Request.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more