DEV Community

Cover image for I've Got a Cute PR
dbelokon
dbelokon

Posted on

I've Got a Cute PR

Hi there!!๐Ÿ˜Š

This week I am going to share my experience on contributing on someone's repo and having someone to contribute on my repo in open source.

Contribution Process

This week was all about contributing to someone's repo by adding a feature. I was working on Irene Park's repo.

The first thing I did, which I had no idea that was the way it was supposed to be done is that I have filed an issue suggesting a feature. I noticed that her repo already supported markdown files with conversion from # to <h1>. So I decided to add a feature that supports strong emphasis, where this **Hello** would be converted into this <strong>Hello</strong> when parsing the markdown file into the HTML file.

Next, when Irene agreed to add this feature to her project, I started analyzing her code. It is been a while since I used Java, but it didn't turn out as bad as I thought. It was interesting to see what her approach was when creating a static site generator.

I started by creating a class called DoubleAsteriskMarkdownParser so that I don't make the Main file messier by adding a new feature. My approach to this problem was that I was relying on a state machine principle. I created internal state for the object and every time the object did an action, the internal state would also change depending on that action. For example, if the object found an asterisk, it will change its state to make a note of that it found an asterisk. Also, if it found another asterisk after that one, it will mark another flag that would imply that a pair of asterisks was found. And I ended up with a cute PR.

I was worrying that my PR wouldn't be accepted because my code wasn't good enough or it will have a huge merge conflict because someone else has contributed with a similar feature earlier than me. So I made sure that they wouldn't be any merge conflicts by pulling the most recent change of her project locally and modifying my changes with that feature so it all works together.

Irene also added a similar feature to my glazed-donut repo. The feature she has added was a Markdown file support that's able to convert all # into <h1></h1>. After some code reviewing, I merged her PR into my master branch. The main thing I was worrying about having someone to contribute to my repo is dealing with merge conflicts or messy PRs. However, Irene followed my code style and did the necessary changes to avoid merge conflicts. I am really grateful for her contribution๐Ÿ˜‹ Now, my static site generator has another cool feature:D

I learned that before working on a feature for someone else's repo, it is really important to file an issue before starting coding, that way you are letting others know that you are working on it. Also, I also didn't know that we had to update each other's README.md files because I assumed that the owner of the repo would do that after merging a PR. Next time, I would file an issue as soon as possible to make sure that I don't miss out on contributing a feature I want๐Ÿฅต.

Top comments (0)