DEV Community

Paul Kim
Paul Kim

Posted on

Working with parallel branches

For this week in Topics in Open Source Development at Seneca College, I was tasked with creating multiples changes across two new feature branches in my til-to-html application for lab 3.

Repository: https://github.com/paulkim26/til-to-html

Issues:

New Features

I added two new features for this week; properly exiting with error codes and adding support for Markdown horizontal rules in my Markdown parser.

The process of implementing the new exit handling logic was simple enough. I added calls to process.exit() within my main entry point. I already caught errors and handled them gracefully, so I added an exit with a return code of 1 to my catch clause.

import parseArguments from "~/parseArguments";

const args = Bun.argv.slice(2);
try {
  await parseArguments(args);
  process.exit(0);
} catch (e: any) {
  console.error(e.message);
  process.exit(1);
}
Enter fullscreen mode Exit fullscreen mode

Adding the horizontal rule Markdown parsing was more involved and required some refactoring. After I added a new parseHorizontalRule.ts module, I had to modify my parse-markdown module to differentiate between block element (headers, horizontal rules) and inline element (bold, italics, links) Markdown. If the Markdown element was an inline element, I would encapsulate the resulting line of html with a <p> tag. If it a block level element, I would not do so, otherwise I would inadvertently wrap i.e. <h1> tags with <p> tags, adding a lot of redundant whitespace.

Merging

I made sure to work with each of these features only within their respective branches. Once I was done, I checked out the main branch and performed a git merge for each branch one after another. The first merge was painless. In the second merge, I had a merge conflict within the readme where I was writing to the same line. I resolved the merge conflict with the VS code merge conflict resolution editor by manually ordering the new lines one after the other. I'm thankful I didn't have further conflicts to fix. I knew from previous experience not to mix and match code changes across branches within the same files/lines.

Thanks for reading!

Top comments (0)