Assignment 4 - Simple Git

Practicing basic Git commands

Objectives

  • Practice the basic Git commands: add and commit and, if necessary, reset
  • Practice with Git branching and merging

Setup

Have a Terminal open with your seng-201/ as the working directory. Run the command:

git clone https://github.com/llayman/assn4-git-calc

This will create a new subdirectory named assn4-git-calc that is a “clone” of a Git repository I created.

Open the assn4-git-calc/ directory in Visual Studio Code. You will see two files, calc.py and .gitignore. You will do all your work in calc.py.

Cloning, GitHub, and the .gitignore file will be explained in an upcoming lab. You can run the clone command again if you need to delete the directory and start over for some reason.

Instructions

Run calc.py and to try it out with the options. You are going to add to the functionality.

Part A: Small, incremental commits

Follow the style in the code. Do not worry about our design rules, unit testing, input validation, or error handling.

  1. Create and checkout a new branch named more-options.
  2. Create a separate commit with a brief, meaningful message for each option below. You must have at least two commits to the more-options branch:
    1. Add a “power” option to raise one number to the power of another. Stage and commit it.
    2. Add a “logarithm” option that computes the log(x, base). Import the standard math library and use the log() function.
    3. The options must be incorporated into the user menu.
  3. All pre-existing options must continue to work, including “Quit”.

Part B: Merge your work into main

  1. Checkout the main branch and use the merge command to merge your more-options branch into main.
  2. Draw a sketch of your branch history after completing the merge in a style similar to the example below from our labs. Use git log to help put it together.
    1. Clearly mark the main and more-options branches and the position of the HEAD.
    2. Take a picture or draw the history in a file. Put the file in your assn4-git-calc/ directory, stage it, and commit it to main.

Part C: Resolving merge conflicts

I have created another branch, rand, that adds random number generation to calc.py. Unfortunately, this will generate merge conflicts with your changes.

  1. Make sure main is the active branch.
  2. Run git merge origin/rand
  3. You must resolve the merge conflicts correctly, meaning:
    1. All of your new options still work.
    2. My random number generation option works.
    3. The user menu and all logic is updated to include all options and quit properly.
  4. Manually run and check all the options.
  5. Stage and commit to main once the merge conflicts are resolved.
  6. Draw a second sketch showing your current branch history.
    1. Clearly mark all three the branches and the position of the HEAD.
    2. Take a picture or draw the history in a file. Put the file in your assn4-git-calc/ directory, stage it, and commit it to main. You can combine it with the previous picture into one file if convenient.

Rubric

Partial credit is not awarded for these items: all or nothing.

  • (5 pts) Two drawings showing correct Git history.
  • (5 pts) Version history of submission shows:
    • a minimum of two commits to the more-options branch
    • a merge commit on the main branch incorporating the changes from the rand branch
  • (5 pts) All options (original features, your additions, and random numbers) correctly work in the final commit.

Submission due November 10

Zip the entire assn4-git-calc/ directory and upload it to Canvas, which will include the hidden .git/ directory containing the local repository. To do this:

  1. Navigate to the directory containing the assn4-git-calc/ folder.
  2. Right-click the folder and select Compress "assn4-git-calc"
  3. Upload the assn4-git-calc.zip to Canvas.
  1. Open the Windows File Explorer
  2. In the Navigation Pane on the left of the Filer Explorer, scroll down until you see “Linux”. Double-click it and then double-click the “Ubuntu” or similarly-named folder.
  3. Navigate to the directory containing your assn4-git-calc/ directory. It should be something like home -> your_name -> seng-201
  4. Right-click the assn4-git-calc/ directory and select Send to... then Compressed (zipped) folder.
  5. Right click in the Explorer window and select Refresh. You should see the zip file.
  6. Upload assn4-git-calc.zip to Canvas.
  1. Open the Files app.
  2. Navigate to the directory contains your assn4-git-calc/ directory.
  3. Right-click the assn4-git-calc/ directory and select Compress..., then click Create.
  4. Upload assn4-git-calc.zip to Canvas.
Last modified November 6, 2024.