Skip to content
AbdulMAbdi edited this page Nov 4, 2020 · 112 revisions

Lab 4

Due Date

Sunday Oct 18 by Midnight.

Overview

This week we are going to practice using git remotes and merges to collaborate with our peers on some code changes. Instead of using GitHub's Pull Request feature, which automates the process, we're going to do this manually using just git.

To accomplish this we'll continue to add a new feature to our link checker repos. This lab will help you practice the following:

  • creating branches to work on new features and fix bugs
  • working on code changes in another project you didn't write
  • using git remote and sharing commits with git push, git pull, and git fetch
  • using git merge and doing practice merges
  • fixing merge conflicts

NOTE: it is highly recommended that you watch this week's video on git remotes before you start this lab.

Feature: Ignore URL Patterns

Users want to be able to run our link checker tools and be able to include an extra argument, a file of URL patterns to be ignored. This week's feature will add the ability to exclude URLs from our check based on a URL pattern file.

Description

For example, imagine you want to check all the URLs in the file index.html, but you want to ignore all URLs that start with https://senecacollege.ca or https://learn.senecacollege.ca. First, create a text file that looks like this:

# Ignore All Seneca College URLs
https://senecacollege.ca
# Ignore all Learn@Seneca URLs
https://learn.senecacollege.ca/

The file is a simple text file where each line is either a URL (line starts with http:// or https://) or an optional comment (line starts with #, and can be ignored).

Assuming we saved that file to ignore-urls.txt, we could use it like this:

$ tool-name --ignore ignore-urls.txt index.html

This would check all URLs in index.html, but ignore and skip any URLs that start with https://senecacollege.ca or https://learn.senecacollege.ca/.

Requirements

The --ignore, -i, \i flag is optional, and if present should take a filepath and use it to load and parse an ignored URLs text file. If the ignore file isn't found, give an appropriate error message. Otherwise, all URLs should be checked against this list to see if they need to be ignored.

Here are some example ignore files.

First, a file with only a comment is valid:

# 1. Empty file, nothing will be ignored

Second, a file with multiple comments and a URL is valid:

# 2. File with a comment and single URL that matches any URL
# that starts with https://www.google.com, for example:
#
# https://www.google.com/index.html would match
# https://www.google.com/ would match
# https://www.google.ca would NOT match
https://www.google.com

Third, a file that has no comments and only URLs is valid:

https://www.google.com

Fourth, a file with anything other than a comment (#) or URL (http://, https://) is invalid:

# This is invalid.  It doesn't use http:// or https://
www.google.com

If the file isn't valid, give an appropriate error message and exit. Otherwise, use the file's URL patterns to test all the URLs being processed, skipping any that match.

Step 1. Pick a Repo to Work In and File an Issue

You are asked to add this new ignore feature to another student's link checker repo. You may NOT add it to your own. Pick a repo from the 0.1 Submissions list, ideally one you haven't worked on before.

Only one student can add the feature per repo. Before you begin, check to see if an Issue is already filed for this feature. If not, file a new Issue in the other student's repo letting them know what you intend to do, and get their permission to start the work (e.g., via Slack or a comment in the Issue on GitHub).

If you notice two people filing the same issue in your repo, make sure you close the second (third, ...) one as a duplicate of the first.

Fork and clone their repo to your local machine.

Step 2. Create and Work on a Topic Branch

Create a branch for this work. If you filed Issue 6, consider naming your branch issue-6.

Do all of your work on this branch, committing changes as you go.

You should also push your branch to your fork on a regular basis. To do so (substitute your branch name for issue-6):

$ git push origin issue-6

Step 3. Collaborate with the Repo Owner

Throughout the week, as you work on the feature, keep in regular contact with the owner of the repo. You are likely going to run into problems, have questions, or need advice on how they want something handled.

Remember, you don't need to do this all by yourself. Make use of the community, talk to people, share your ideas and questions. Open source is about collaboration. Use Slack and the GitHub Issue you filed to discuss your work.

Step 4. Complete the Feature

As you work on the feature, commit and push all the changes on your branch to your fork:

$ git checkout issue-6
$ git push origin issue-6

Let the other student know that you're done in the GitHub Issue, and ask them to add your fork as a remote, fetch, and test your branch (see Step 5 below).

They will likely have feedback for you as you go, and ask you to make some changes. They may also want to share a branch with you, based on your changes. Work with the repo owner to get the code ready to be merged.

Step 5. Reviewing and Testing via Remotes

Normally we use GitHub Pull Requests to review and merge work from collaborators. This time, we'll use git remotes instead. For this to work, we'll need to add remotes, and share commits and branches between each other.

If your repo is being worked on by another student, get them to tell you the name of their fork and the name of the branch they are working on. Next, add them as a remote to your local repo:

$ git remote add <name-of-student> <https://git-url-of-other-studnet-fork.git>

Next, fetch their work into your local repo:

$ git fetch <name-of-student>

Now set up a tracking branch in your local repo, so you can track the work on their branch (substitute the name of the student and branch for issue-6):

$ git checkout -b issue-6 <name-of-student>/issue-6

Use this branch to review and test their work. Don't commit to it, though. We'll leave it "clean" of our changes.

If you ever need to update your local issue-6 branch to see new changes the other student has pushed to their fork, you can do that with git pull:

$ git checkout issue-6
$ git pull <name-of-student> issue-6

NOTE: if you do want to commit something to it, start a new branch first (substitute the name of the student and branch for issue-6):

$ git checkout -b issue-6-fix <name-of-student>/issue-6
$ git add file
$ git commit -m "Fixing x, y, z..."
$ git push origin issue-6-fix

You can share this work with the other student by having them add your repo as a remote and fetching:

$ git add upstream <https://git-url-of-original-studnet-repo.git>
$ git fetch upstream
$ git checkout -b issue-6-fix upstream/issue-6-fix

Now they can look at or test your work on the issue-6-fix branch. They might also decide to git merge it into their existing issue-6 branch:

$ git checkout issue-6
$ git merge issue-6-fix

If you have any trouble working with git during this process, make sure you ask for help in Slack.

Step 6. Merge the Feature When Ready

When you have completed working on the feature, and fixed any issues your reviewer has made, commit and push all the changes on your branch to your fork:

$ git checkout issue-6
$ git push origin issue-6

Let the other student know that you're done in the GitHub Issue, and ask them to look over your latest changes on your branch.

If they are satisfied, they can merge your work and push it to their upstream repo:

$ git fetch
$ git checkout master
$ git merge <student-name>/issue-6
$ git push origin master

Check the original upstream repo's master branch, and make sure this new work is all there. If it is, close the Issue and complete the submission below. If it isn't, figure out what went wrong, and get help on Slack.

Step 7. Write a Blog Post

Write a blog post about the process of working on this new feature using remotes. First, how did the code itself go? Did you run into any problems? How did you tackle the work? Second, how did it go using git? Did you find any of it difficult? How did you get around this? What would you do differently next time? What did you learn from the experience?

Submission

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

Name Blog Post (URL) Issue URL Merge Commit URL on upstream master
Example Name https://example.com/blog/1 10 ddeaf180
Khoi Nguyen Vu (Tony) https://medium.com/@tonyknvu/learned-another-powerful-git-command-to-save-my-life-on-a-rainy-day-dc3dca34c1e3 10, 11 adf3cf3 , 9b4e263
Paul Sin README 16, 17 86128dbc
Hyunji Lee https://hyunjijanelee.blogspot.com/2020/10/lab4-practice-git-remotes-and-merges.html 9 To be updated / PR
Roger Yu https://ryudeveloper.wordpress.com/2020/10/16/lab-4-git-remotes/ 8 28883bdc
Ekaterina Grinberg https://egrinberg.medium.com/lab-4-dps909-73c8c3df9665 12 578e722, fc3d954
Muskan Shinh https://muskanshinh.wordpress.com/2020/10/18/lab-4/ 6 8adf38f
Eunbee Kim https://ekim105.wordpress.com/2020/10/16/avoid-to-broken-code/ 14 ed4bf2e
Junyong Liu https://jliu396.blogspot.com/2020/10/osd-600-lab4.html 12 c53f6c9, e90c3bb
Michael Brackett https://dev.to/mljbrackett/osd-lab4-35l0 7 228fff4, 1e21f76, aa43a46
Chris Pinkney https://dev.to/chrispinkney/remotes-commits-and-merges-oh-my-5ge8 14 3cc6f495
Plamen Velkov https://plamenvelkovtech.blogspot.com/2020/10/lab-4-more-python-nightmares.html 26 1a6c3fd
Mintae Kim https://mintaedotblog.wordpress.com/2020/10/16/lab4-git-remote-and-merge/ 6 8146f9a
Sanjida Afrin https://medium.com/@safrin2/new-feature-on-link-checker-tool-e778a78b9ded 10 ed0c03d
Yifan Zhao To be updated 7 df981f8
Jie Yang https://jyangblogs.wordpress.com/2020/10/17/git-remote/ 13 e83fe72
Stella Jung https://sostellajung.blogspot.com/2020/10/how-to-communicate-with-other-people.html 13 a31ea17
Abu Zayed Kazi https://www.abuzayed.ca/my-blog/osd600/2020/10/18/lab-4/ 14 c3a9da3, 4d02541, d444fea, 4e896a9
Leon Li https://gonewiththewind1982.blogspot.com/2020/10/practice-git-remote-and-git-merge-in.html 17 58536f9
Tim Roberts https://dps909tddr.tech.blog/lab-4-mix-master-manual-merger/ 7 899b4c0, d04121a, 246ca6b
Matthew Stewardson https://matthew-k-stewardson.blogspot.com/2020/10/week-5-lab-4.html#more 17 16 0b4f5cb
Yuan-Hsi Lee https://dev.to/yuanleemidori/git-remote-192p issue#20 42f554
Minh Huy Nguyen https://x7z.net/lab04-osd600 24 463e05e
Thomas-Jayrell LeBlanc https://tjstavern24697521.wordpress.com/2020/10/18/lab-4-ignoring-urls-but-not-git-remote-issues/ 9 58a2dfd
Thanh Tien Phat Nguyen To be updated 6 ddeb53e
Wei Huang https://weihuangosd.blogspot.com/2020/10/git-remote.html 7 b7ab995
Joey Assal https://osd600-joey-assal.blogspot.com/2020/10/osd600-lab-5.html 15 9 95c7
Raymond Rambo https://dev.to/fluentinstroll/let-s-merge-a-remote-26j0 1 To be updated
Zongwei Yang https://dev.to/yzwdroid/lab-4-reinvent-pr-by-remote-repos-alo issue-16 c1a7d4e 5d0d3376
Kimin Lee https://dev.to/klee214/add-i-ignore-option-to-insane-cli-finding-broken-url-cli-program-a9h issue-10 To be updated (PR)3c0fe4d
Anthony Slater dev.to/slaterslater 11 246ca6b
Nesa Bertanico Ignore-Me-Not issue-13 a88601f
Palak Chawla https://palak-chawla.blogspot.com/2020/10/lab-4-hustle.html Issue-6 bf4e7d3 , f583339 , 4de3280
Jasper Mui https://muioverflow.wordpress.com/2020/10/18/ignore-url-features/ Issue-10 c43befc
Joel Azwar https://joelazwaros.blogspot.com/2020/10/im-almost-git-ting-it.html Issue-10 30e9766
Xiaolu(Isabella) Liu https://dev.to/isabellaliu77/another-format-of-pr-which-i-am-not-a-fan-of-3f3c issue-7 a41b2d6
Royce Ayroso-Ong https://medium.com/@roycedev/upstream-without-a-paddle-8114571da80e 8 2730676
Jennifer Croft https://dev.to/strawberries73/osd600-lab4-remotes-and-merges-1fde Issue-9 0268201e
Abdulbasid Guled https://dev.to/hyperthd/lab-4-fetch-merge-commit-push-pull-just-do-them-all-39am https://github.com/Metropass/url_tester/issues/12 e8e7d243
Mohammed Ahmed (Mo) https://medium.com/@moho472/lab-4-git-galore-4ca61631da2a https://github.com/HyperTHD/URLAutomationMachine/issues/6 d1bd9813,e40a0b,b5805ebb,da794afe,0693862
Philip Golovin https://1jz.tech.blog/2020/10/18/remotes-and-merges/ 3 78b1f8d, 7f1e948
Zong Jin Jiang https://zjjiang2.blogspot.com/2020/10/lab-4-blog.html 14 8b754dec
Mohammed Niaz Ul Haque https://dev.to/niazulhaque/well-just-remot-ed-hacktober-updates-exam-weeeeeek-4fai 13 a4e9a5b17
Pedro Fonseca https://medium.com/@pedrofonsecadev/git-df5350ce1c26 11 ddeb53ea
Matthew Ross Why Ignoring Is Useful Issue 6 5fc3af1e, fa957a5c, 9108e020, 62871daf
Nathan Pang https://osdnathanp.wordpress.com/2020/10/19/lab-4/ Issue 7 0cd04cc3
Mamadou Diallo https://mamadou--diallo.blogspot.com/2020/10/lab-4-git-remotes-and-marges.html Issue 11 f8392ba
Ruby Anne Bautista https://medium.com/@rabautista/its-not-a-pr-1409c302c26c https://github.com/rjayroso/haystack-link-checker/issues/15 d567080
Devansh Shah https://dev.to/zg3d/git-remote-ignores-all-features-3n39 https://github.com/tonyvugithub/GoURLsCheckerCLI/issues/11 93f96f3
Abdul Abdi https://abdulosd.blogspot.com/2020/11/remotesandmerges.html Issue 14 5fc3af1