Code Submission Reference

Contents:

Turning in your code

Step 1. Commit all your code

See the version control handout for details on how to do this.

Step 2. Create a tag marking your most recent commit.

To turn in your code:

To create a tag, follow Git » New Tag... in IntelliJ. By default, the tag is placed on the most recent commit that you've made. This means that, when you're placing a tag, you should make sure you've committed all your work so the TA will see your completed code. We will grade all work up-to and including the work done in the commit that's tagged.

At the bottom of each assignment, we specify a specific tag name that you need to use to mark your final code submission for that assignment. You must use the correct tag name, or your assignment has not been submitted. Tags are case-sensitive.

When you create a tag, DO NOT add a message. Adding a tag message changes what kind of tag is created, and can cause problems later on. You should name the tag appropriately, but leave the tag message blank.

Step 3. Pushing a Tag to GitLab

When you create a tag, it's created in your local repository only, just like commits. In order to let GitLab know that you made a new tag, you need to push the tag, just like commits! Unfortunately, tags aren't included in a normal push, so follow Git » Push as usual, but make sure the "Push Tags" checkbox in the bottom left corner is checked.

The above works just like a normal git push, except it also includes tags in the push. Be sure that tags are pushed, otherwise TAs will not be able to find your assignment when we get to grading!

Step 4. Double-Checking Your Assignment

You are responsible for ensuring that your submission appears in the gitlab repository (with the appropriate tag) as you intended it. We will only grade what appears in gitlab, not what is on another machine.

Here are some additional checks that you can perform to ensure that this is the case. The first item will catch most problems. The second, while more time consuming, is more foolproof.

  1. Check the status of your gitlab runner. The runner runs each time you push the final tag for an assignment. Browse to https://gitlab.cs.washington.edu/cse331-QUARTER-students/cse331-QUARTER-MyCSENetId/-/pipelines to see the pipelines for your repository. Look for the pipeline marked with the assignment you just submitted. If there's a green check-mark, the pipeline has passed. If there's a red X, the pipeline has failed. Click the red X for details about the failure, fix whatever caused the issue, and re-submit your code.
  2. Check that everything is properly stored and tagged in your repository
    • Login to attu. See the software setup handout for details on how to do this.
    • (First time only) Set up the ssh key on attu.
      1. Generate an RSA key pair.

        bash$ ssh-keygen -o -t rsa -b 4096 -C "your@email.com"
        

        • Press enter when asked for a file name (use default)
        • No passphrase
        • You’ll be told: “Your public key has been saved in (…)”
      2. Copy the the generated public key - run the below command and then copy its output.

        bash$ cat ~/.ssh/id_rsa.pub
        

      3. Paste that into your GitLab account, under “Profile” -> “Settings” -> “SSH Key”. Sign in at Gitlab.
    • Clone a fresh copy of your project and checkout the commit with a specific tag. Do this:

      bash$ git clone git@gitlab.cs.washington.edu:cse331-QUARTER-students/cse331-QUARTER-MyCSENetId.git
      bash$ cd cse331-QUARTER-MyCSENetId
      bash$ git checkout hwN-final
      

    • Run the gradle task that is instructed on the homework assignment. Make sure that the project is properly compiled and your code has passed.

      bash$ ./gradlew GradleTaskName
      

    • Remove the repository once you are done.

      bash$ cd ..
      bash$ rm -rf cse331-QUARTER-YourCSENetID
      

Special Cases

Listed below are some special cases that don't necessarily apply to every submission. See below if it's relevant to your situation.

Using a Late Day (Turning in your Assignment Late)

To use a late day, do not tag your repository on the day it is due. Instead wait to tag your repository once you complete the homework (before the late day deadline)!

Deleting/Moving a Tag (Re-Submitting an Assignment)

If you've already created and/or pushed a tag, but you decide to take a late day or make change to your code and want to move the tag, do the following. Since removing tags is a little more complicated and is fairly rare, there isn't a menu for this in IntelliJ. We'll need to use the IntelliJ terminal window for a few steps (the same terminal you may use to run gradle tasks). (Windows users may need to run these commands from Git Bash instead of the terminal. Contact the course staff if need help with this.) The basic process is broken down into four steps:

Note: Some mac users may recieve an error message or a request to install xcode or the command line developer tools when running the git command from the IntelliJ terminal. Instead of typing just git, use /usr/local/bin/git. If you're still having issues, contact the course staff for help.

To remove the old tag, run the following command from the IntellIJ terminal. (The "-d" means "delete".)

bash$ git tag -d TAG-NAME-HERE

To remove the tag from GitLab, run the following. This will remove the tag with whatever name you specify from GitLab. This needs to be done separately because of how tags behave in git. If you tried to push the new tag without removing the old one from GitLab first, you'd get an error.

bash$ git push origin master :refs/tags/TAG-NAME-HERE

Create the new tag on your updated code. Depending on the situation, you may want to tag your most recent commit or you may want to go back and tag some earlier commit in your history. To tag the most recent commit, simply follow the Creating a Tag (Step 2) instructions above. To tag an older commit in your history, follow the instructions in the "Tagging an Old Commit" section to follow. Once you have a tag in the right place, push it to GitLab as described in the Pushing a Tag to GitLab (Step 3) section above. If you get an error about the tag already existing, make sure you have deleted the old tag from GitLab by running the above command.

Tagging a Wrong Commit

Sometimes, you need to put a tag on a specific commit in your repository. For example, this happens if the tag wasn't in the right place when you originally submitted your code, but you've already been working on the next assignment and have newer commits in your repository. To do this, there are two main steps: (a) figure out which commit you want to put the tag on, and (b) put the tag on that specific commit.

(a) Locate the Correct Commit to Tag

Using GitLab
  1. Open your repository in the GitLab web interface by navigating to https://gitlab.cs.washington.edu/cse331-QUARTER-students/cse331-QUARTER-NETID. Make sure to replace QUARTER with the current quarter, and NETID with your netid.
  2. On the left options bar, navigate to Repository > Commits. On this page, you see the entire history of your repository, with the newer commits at the top and the older commits at the bottom.
  3. Decide which commit you want to move the tag to. To help you, you can click on each commit message to see the exact changes that were made in that commit. You can also mouse-over the time in "NAME authored TIME ago" under each commit message to see the exact date/time of that commit.
  4. Once you've decided which commit you want to move your tag to, copy the SHA for that commit - you'll need it for the next part. The SHA is a string of letters and numbers that uniquely identifies the commit - you can think of it as the "name" of the commit. On the GitLab commits page, each commit's SHA is listed next to it on the right side of the page. An example SHA might be: 42fbcd22.
Using the Terminal

  1. Open terminal from within IntelliJ.
  2. View your Git Log by entering the command:
    bash$ git log
    You can now browse your log using up and down directional keys on your keyboard.
  3. The commit with the tag is marked with the tag name (ex: section-demo or hw7-final) .
  4. The current commit SHA for the commit that was graded is indicated here.
  5. You may now look at the times, and commit messages of different commits to determine which commit includes your final changes to your repository that you intended the course staff to grade. If the current commit is not your intended commit you can use the "Deleting/Moving a Tag" to delete the current tag and move it to the correct commit.

(b) To Tag a Specific Commit

  1. Now that you have the SHA of the commit you want to tag, open your project in IntelliJ and open the Git » New Tag... window.
  2. Enter the tag name as usual. In the "Commit" field, paste the SHA that you copied from earlier. (If desired, you can click "Validate" once you've pasted the SHA and IntelliJ will show you the commit you've selected, to double-check that you have the right one.) Do not enter a message.
  3. Click "Create Tag" to finish placing the tag on your selected commit. (Note: if you're moving a tag from an older commit, you need to delete the old tag before you do this. See the "Deleting/Moving a Tag" instructions above.)
  4. Now that you have the new tag, follow the instructions in Pushing a Tag to GitLab above to push that tag as usual.