lab 3 - humphd/topics-in-open-source-2024 GitHub Wiki

Lab 3

Due Date

Friday Sept 27 by Midnight.

Overview

This week we are going to practice using git to manage multiple simultaneous changes in a single project, and use git merges. To do this we'll continue to add some features to our 0.1 repos. This lab will help you practice the following:

  • creating multiple branches to work on new features and fix bugs
  • working on multiple code changes in parallel on separate topic branches
  • adding features to existing code
  • using git merge to do fast-forward and three-way-recursive merges
  • fixing merge conflicts
  • how to find and identify commits on GitHub

Step 1. Pick your Features

You are going to make changes to your own 0.1 repo (i.e., you can work on your own code this week). Pick 2 of the following features to add to your project:

  1. Support multiple files and/or folder arguments. It should be possible to pass your tool multiple files and/or folder paths, and the files within should get processed.
  2. Make sure that the program exits with appropriate error codes and helpful error messages (stderr) in all cases. If there are no errors, exit with 0. Otherwise, exit with a non-zero exit code (e.g., 1).
  3. Add support for another provider other than the one(s) you currently use. For example, add support for Cohere, Gemini, Grok, OpenAI, OpenRouter, etc. Talk to your classmates who already use these providers to get tips on how to do the integration.
  4. Allow using multiple models at once. The user should be able to specify multiple models, and output files should get generated for each model, allowing for comparisons.
  5. Add support for streaming responses with --stream/-s. When writing to stdout you will stream the response live as it updates vs. all at once at the end.
  6. Add support for using a .gitignore file to exclude files/folders when processing a directory. If the user has a .gitignore, parse it and use that to build filesystem glob patterns to ignore
  7. Pick another feature to implement of your own choosing. Confirm that it's OK with your professor (it probably is).

In your project's GitHub repo, file Issues for each of the two features you want to add, and discuss the changes you will make in the Issue's descriptions. Make sure the Issues are complete and detailed.

Step 2. Create Topic Branches

For each of your chosen features, create a new, separate topic branch. For example, if you filed Issue #10 and Issue #11 you need to create 2 new topic branches off of main:

$ git checkout main
$ git checkout -b issue-10
$ git checkout -b issue-11

All work for Issue #10 should happen on the issue-10 branch. All work for Issue #11 should happen on the issue-11 branch. None of your work should happen on main (we'll only merge there). All work should be done on one of the topic branches you just made.

NOTE: you switch between your branches using git checkout issue-10 or git checkout issue-11 (use your branch names). You can only switch branches if your working directory is clean (i.e., you committed any changes).

Step 3. Implement Your Features

Throughout the week work on your two features. You are free to discuss strategies and ideas with your classmates, but you must do your own work in the respective branches you created above (no pull requests this time, sorry!).

Your two features will likely involve modifying the same files and/or functions. This is fine and to be expected. Resist the desire to share any code between branches! Keep all work for each feature in its own topic branch, and touch as little code as possible in each branch. The less code you change, the easier it will be to merge everything later.

You can work on the features one after the other, or in parallel, but you may not merge until both are done! With software, it's common and often helpful to do more than one thing at a time: if you get stuck on one, you can switch to the other.

One of git's powers is to allow you to have many different versions of the same code all in existence at the same time. This lets you quickly move back and forth between different projects on the same repository, without having to worry about losing your work.

Remember to git add and git commit as you go, and put all your commits on the correct branch. Every change for Issue #10 goes on the issue-10 branch, etc.

Step 4. Merge Your First Feature Branch

When you have completed both features, and each branch contains the necessary code, it's time to merge.

We merge into a branch, so start by switching to your default branch (i.e., main) and merge the first feature branch (e.g., issue-10):

$ git checkout main
$ git merge issue-10

This merge should go smoothly, and assuming you haven't changed anything on main since you created your topic branches, git will do a fast-forward merge. Confirm that it did, using git log. If it didn't, determine why not.

Step 5. Merge You Second Feature Branch

After you've merged your first branch, it's time to merge the second (e.g., issue-11):

$ git checkout main
$ git merge issue-11

This merge will likely require a three-way recursive merge, since git can't fast-forward your main branch. You may also need to deal with merge conflicts.

Make sure you fix any/all merge conflicts before you complete the merge. If you need help, ask on Slack.

When you're done, the main branch should contain the code for both feature branches, and both features should be working. Make sure your merges didn't break anything!

Test, test, test, and test again. Is the main branch still working? Do you need to fix anything before going to the next step? If so, commit to main to correct the problem(s). Keep track of this, and discuss in your blog below.

Step 6. Push your Main Branch to GitHub

Push your fully merged and tested main branch to GitHub:

$ git push origin main

Step 7. Close your Issues

Close your original issues, and provide a link in the comments to the merge commit on GitHub that closes the feature. On GitHub the URL for a commit follows this format:

https://github.com/username/project-name/commit/commit-sha

For example, the 11a9e21d73df8cbd67db7163b42b30e052fbcca0 commit (which we can shorten to 11a9e21) for this repo is at:

https://github.com/Seneca-CDOT/topics-in-open-source-2021/commit/11a9e21d73df8cbd67db7163b42b30e052fbcca0

When you close your issue, add a comment like this:

Closed by https://github.com/Seneca-CDOT/topics-in-open-source-2021/commit/11a9e21d73df8cbd67db7163b42b30e052fbcca0

Step 8. Write a Blog Post

Write a blog post about the process of working in parallel branches in your project. In your post, include links to everything you discuss (e.g., the project repo, your issues, your merge commits).

Discuss what you did, the changes you made for your features, and the process of doing your merges. What problems did you have? What did you learn? What would you do differently next time?

Submission

When you have completed all the requirements above, please add your details to the table below.

Name Blog Post (URL) Issues URLs Merge Commit URLs
Majd Al Mnayer OptimizeIt: Merge Conflicts & Three-Way-Recursive merges 14, 15 679a7b1, 45137a2
Cleo Buenaventura Learning three-way recursive merge 14, 15 1f7222d, 3d0b9cf
Nonthachai Plodthong Git Merge ChatMinal 10 , 11 55d0fa , 3fc5152
Krinskumar Vaghasia https://dev.to/krinskumar/merging-branches-lab-03-19ne 6 7 947c74d 4781f16
Lily Huang https://wordpress.com/post/vriskaserket2.wordpress.com/89 15 16 b2a8f89 daacc4b
Rong Chen https://dev.to/elisassa/osd-lab3-9dm 3 4 ff7fe31 2cd0189
Kannav Sethi https://dev.to/kannav02/merge-conflicts-and-three-way-merges-3365 22 , 23 a8cd0a3 , 38a0918
Bregwin Jogi https://dev.to/bregwin/dealing-with-merge-conflict-trauma-osd6005-74j 6 , 7 051dad8, b652f5b
Theo A Rusty Three-Way Merge #16, #17 d6d8bfc, 86a366a
Uday Rana https://dev.to/udayrana/learning-how-git-merge-works-3k4k #27, #34 8c0288e, 9dd8cab
Hyunjin Shin https://dev.to/jinger-ale/lab03-ej9 issue 10, issue 11 6610de5, b10417a
Vinh Nhan TBD Issue #16, Issue #17 Issue #16, 4446d7, Issue #17, 42532fa
Peter Wan https://dev.to/peterdanwan/gitting-funky-with-git-merge-5dpm Issue #11, Issue #30 4dd7dab, 45cffa9
Abdullah Al Mamun Fahim https://dev.to/aamfahim/fast-forward-merge-vs-three-way-recursive-merge-34e1 #26, #27 5dffb , 29c31
Anh Chien Vu https://dev.to/anhchienvu/working-with-merge-in-git-752 #15, #16 90d75a4 , dd671de
Harshil Patel https://dev.to/harshil_patel/working-simultaneously-on-different-branches-and-merging-them-2mbf #19, #18 80368e8 , 56d0384
Aldrin Fernandez https://dev.to/aldrin312/lab-3-branch-merging-4d6f #9, #10 917d57c, cd982fb
Henrique Sagara https://dev.to/htsagara/handling-merge-conflicts-in-git-how-to-fix-and-prevent-them-1m62 #6, #8 229defe, 43967e
Liam Hutchinson https://dev.to/mpalhutchinson/week-4-lab-4-merge-branches-4bop #6, #7 504c3ab, 32650c4
Inderpreet Singh Parmar Implementing Multi-Model and Provider Support in Tailor4Job: Handling Merge Conflicts #6, #7 51e20de, f5f6e4d, 0629419
Christian Duarte https://dev.to/cduarte3/week-4-lab-3-54md #11, #12 c9ef383, 9ed3394
Adam Davis Parallel Branches in Git #10, #12 d73f33d, 83d85ae
Arina Kolodeznikova working-on-different-branches&merging #6 #7 343fa83 4bf64b2
Ajo George https://dev.to/ajogseneca/docbot-new-feature-update-205k #7,#9 60d3b22,97cdded
Amir Mullagaliev MERGE TIME! #7, #8 acd8b83, e478781
Andrii Sych https://dev.to/sych_andrii/fast-forward-and-three-way-merges-3kl5 #33, 34 b01f493,c2248b
Tasbi Tasbi https://dev.to/tasbi03/tackling-merges-conflicts-and-new-features-in-readcraft-7jd 8 , 9 092caeb , 4b8f74e
Mayank Kumar https://dev.to/mayankpareek/understanding-git-merge-4lc2 #15, #16 3abdc21, 7b0cd68
Madhur Saluja https://dev.to/msaluja/code-complexity-pro-conquering-multi-file-support-and-error-chaos-78f 7, 8 d309865,37e20e8
Fahad Ali Khan Working in Parallel Branches Issue: #7, #9 ff60d 88d40f
Aryan Khurana https://aryank1511.hashnode.dev/my-open-source-journey-week-03 #44, #45 7f7889, 32abf5