-
Notifications
You must be signed in to change notification settings - Fork 25
Implement exercise T4L2/tags-update #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
tags_update/verify.py
Outdated
| MISSING_COMMIT_MESSAGE = "Could not find a commit with '{message}' in the message" | ||
|
|
||
|
|
||
| def find_commit_by_message(exercise: GitAutograderExercise, message: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar in functionality with get_target_commit_sha from log_and_order/verify.py, but more flexible and simpler logic.
|
Opened PR early while waiting to be assigned. Feel free to close if there are duplicates in the future, or if someone else is assigned to this exercise in the future. This would serve as potential reference to others looking for implementations of exercises as well. |
woojiahao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jovnc for working on this exercise! I think that there are some major comments on the ordering of grading, less on the coding style, more so on the autograding philosophy. I will need to update the public documentation to capture this logic too
tags_update/download.py
Outdated
| run_command(["git", "tag", "first-update", "HEAD~4"], verbose) | ||
| run_command(["git", "tag", "april-update"], verbose) | ||
| run_command(["git", "tag", "may-update"], verbose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is repeated multiple times, could we get it as a utility function for future use?
tags_update/verify.py
Outdated
| # Verify that the tags exist and that the old first-update tag is deleted | ||
| if "first-update" in tags: | ||
| raise exercise.wrong_answer([OLD_FIRST_UPDATE_TAG]) | ||
| if "january-update" not in tags: | ||
| raise exercise.wrong_answer([MISSING_JANUARY_TAG]) | ||
| if "april-update" not in tags: | ||
| raise exercise.wrong_answer([MISSING_APRIL_TAG]) | ||
|
|
||
| # Get correct commits that the tags should point to | ||
| january_commit = find_commit_by_message(exercise, "Add January duty roster") | ||
| if january_commit is None: | ||
| raise exercise.wrong_answer([MISSING_COMMIT_MESSAGE.format(message="January")]) | ||
|
|
||
| april_commit = find_commit_by_message(exercise, "Update duty roster for April") | ||
| if april_commit is None: | ||
| raise exercise.wrong_answer([MISSING_COMMIT_MESSAGE.format(message="April")]) | ||
|
|
||
| # Verify that the tags point to the correct commits | ||
| january_tag_commit = tags["january-update"].commit | ||
| if january_tag_commit.hexsha != january_commit.hexsha: | ||
| raise exercise.wrong_answer([WRONG_JANUARY_TAG_COMMIT]) | ||
|
|
||
| april_tag_commit = tags["april-update"].commit | ||
| if april_tag_commit.hexsha != april_commit.hexsha: | ||
| raise exercise.wrong_answer([WRONG_APRIL_TAG_COMMIT]) | ||
|
|
||
| return exercise.to_output( | ||
| [SUCCESS_MESSAGE], | ||
| GitAutograderStatus.SUCCESSFUL, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense that the grading following the order of the tasks provided. The rationale is that students may attempt each task and run gitmastery verify immediately after. So if the autograding provides feedback for tasks later down the line, they might not really understand the feedback.
For instance, in this exercise, the first task is to rename the first-update tag to january-update. So you would want to
- Ensure that
first-updatedoes not exist - Ensure that
january-updateexists - Ensure that the
january-updatetag points to the right commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that, I like the comprehensiveness of the checks. But I think it would greatly benefit from a little reshuffling!
| def test_wrong_april_tag(): | ||
| with loader.load("specs/wrong_april_tag.yml", "start") as output: | ||
| assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [WRONG_APRIL_TAG_COMMIT]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would also want to ensure that the same check for the January tag commit should exist too, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, would make the tests more comprehensive!
| def tag(tag_name: str, verbose: bool) -> None: | ||
| """Tags the latest commit with the given tag_name.""" | ||
| run_command(["git", "tag", tag_name], verbose) | ||
| def tag(tag_name: str, verbose: bool, commit_ref: str | None = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is repeated multiple times, could we get it as a utility function for future use?
There is an existing tag function under exercise_utils.git, however, it doesn't support tagging a specific commit hash.
We have 2 options:
- extend current utility of the
tagfunction to take in optionalcommit_ref - create a command with a more verbose name
tag_with_committhat serves the same purpose astagbut takes in compulsorycommit_ref
I have chosen the first option, as it keeps backward compatibility, while ensuring simplicity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to open a new PR to add this change for the util, or can I include it in this PR? Is there anywhere I need to document this change?
|
@woojiahao Thanks for the PR review, and the very detailed comments. I have made the changes based on your comments, namely here are the main changes:
|
Exercise Review
Exercise Discussion
Fixes #62
Checklist
Git-Masteryorganization, have you created a request for it?repo-smithto validate the exercise grading scheme?test-download.sh?git-autograder?app?