DEV Community

kkrishnan10
kkrishnan10

Posted on

Lab 3: OSD600

Repository and Issues

For Lab 3 I worked on my own repository ContextWeaver. I created two issues to represent the features I wanted to implement. Issue #3 described adding a verbose mode flag, while Issue #4 described adding a line numbers mode. Each issue was linked to its own topic branch, and when both were complete they were merged into the main branch. The merge commit can be seen here: https://github.com/kkrishnan10/ContextWeaver/commit/f6e5cb7.

What I Did

To begin, I created two separate topic branches, one for each issue. On the branch for Issue #3, I implemented a verbose mode feature. This feature adds a --verbose or -V flag, which prints progress messages to stderr while scanning and reading files. For example, the tool now outputs “Processing directory: …” and “Reading file: …” so that the user can see what it is doing. On the branch for Issue #4, I implemented a line numbers feature. This feature adds a --line-numbers or -l flag that prefixes each output line of file content with its one-based line number. This makes the output easier to read, especially for code review or debugging. I committed each change with clear messages and pushed the branches to GitHub after testing.

The Process of Merging

Once both features were complete, I turned to the merging process. First I ensured my main branch was in sync with origin/main. I then merged the branch for Issue #3 into main. Because the histories had not diverged, this merge was completed as a fast-forward merge. Next, I attempted to merge the branch for Issue #4. Since both branches had modified the src/main.py file, this merge required a three-way recursive merge. Git flagged conflicts in the argparse section of the code where the command-line options are defined. I opened the conflicted file, carefully combined the changes, and kept both the verbose option and the line numbers option. After resolving the conflict, I committed the merge and pushed the updated main branch to GitHub.

Problems I Faced

During this lab I encountered two main problems. The first was the merge conflict in src/main.py while merging the line numbers branch. Since both branches edited the same argparse block, Git could not automatically combine the changes. I solved this by manually editing the file to include both new flags. The second problem occurred when trying to push my changes. Sometimes my local branch was behind the remote main, so Git rejected the push. I fixed this by rebasing my work on top of the updated remote branch and then completing the merge. These problems slowed me down, but they gave me practice with real Git workflows.

What I Learned

From this work I learned how to manage multiple branches in parallel and why they are useful for separating feature development. I saw the difference between fast-forward merges, which happen when the main branch has not moved ahead, and three-way recursive merges, which are required when histories diverge. I also learned how to resolve merge conflicts carefully so that no feature is lost in the process. Finally, I recognized the importance of testing after merges to confirm that the combined code works as expected.

What I Would Do Differently Next Time

If I were to repeat this process, I would rebase each feature branch onto the latest main before attempting to merge. This would reduce the likelihood of conflicts and make the merges cleaner. I would also make smaller, more frequent commits so that my history is easier to follow and conflicts are simpler to resolve. In addition, I would test combinations of features earlier in the workflow, instead of waiting until both branches were merged, to catch problems before they became bigger.

Final Result

In the end, both features now work on the main branch. Running python3 -m src.main . -V enables verbose mode, while python3 -m src.main . -l adds line numbers to the file content output. Both flags can also be used together, which results in progress messages printed to stderr and numbered lines in the file content. The README.md has been updated with usage examples, and both issues have been closed with comments linking to the merge commit. This lab gave me practical experience in working with parallel branches and merging them into a stable main branch.

Top comments (0)