Skip to content

Conversation

@jovnc
Copy link
Collaborator

@jovnc jovnc commented Dec 15, 2025

Exercise Review

Exercise Discussion

Fixes #145

Checklist

  • If you require a new remote repository on the Git-Mastery organization, have you created a request for it?
  • Have you written unit tests using repo-smith to validate the exercise grading scheme?
  • Have you tested the download script using test-download.sh?
  • Have you verified that this exercise does not already exist or is not currently in review?
  • Did you introduce a new grading mechanism that should belong to git-autograder?
  • Did you introduce a new dependency that should belong to app?

@jovnc jovnc self-assigned this Dec 15, 2025
@jovnc
Copy link
Collaborator Author

jovnc commented Dec 15, 2025

Repo-smith currently does not support reset step, hence we need to implement this.

In addition, when cloning from remote repository, the default branch seems to be still master branch instead of main branch. We might need to streamline this for remote repositories as well.

@jovnc jovnc changed the title [sensors-reset] Implement exercise T4L5/sensors-reset Implement exercise T4L5/sensors-reset Dec 15, 2025
@damithc
Copy link
Contributor

damithc commented Dec 15, 2025

In addition, when cloning from remote repository, the default branch seems to be still master branch instead of main branch. We might need to streamline this for remote repositories as well.

Isn't the default branch is inherited from the cloned repo? i.e., same as the cloned repo

@jovnc
Copy link
Collaborator Author

jovnc commented Dec 15, 2025

@damithc Yes, the default branch is inherited from the cloned repo. In this case, when we clone https://github.com/git-mastery/gm-sensors, the default branch would be master. However, most of the tooling in repo-smith and this folder itself, eg. init functions seems to assume main as default.

eg. repo-smith tests defaults to main by default
eg. init in exercise_utils uses main by default

This inconsistency can lead to documentation inconsistencies, as well as some issues in verification process, eg. as shown below. We expect master branch since when we clone the default branch is master. However, for repo-smith tests, it assumes default is main, hence causing errors in testing.

master_branch = exercise.repo.branches.branch_or_none("master")

Though a possible solution would be

branch = exercise.repo.branches.branch_or_none("master") or exercise.repo.branches.branch_or_none("main")

@damithc
Copy link
Contributor

damithc commented Dec 15, 2025

@damithc Yes, the default branch is inherited from the cloned repo. In this case, when we clone https://github.com/git-mastery/gm-sensors, the default branch would be master. However, most of the tooling in repo-smith and this folder itself, eg. init functions seems to assume main as default.

eg. repo-smith tests defaults to main by default eg. init in exercise_utils uses main by default

This inconsistency can lead to documentation inconsistencies, as well as some issues in verification process, eg. as shown below

master_branch = exercise.repo.branches.branch_or_none("master")

Though a possible solution would be

branch = exercise.repo.branches.branch_or_none("master") or exercise.repo.branches.branch_or_none("main")

hmm... we probably have to migrate the entire git-mastery to use one (main or master) as the default branch. I don't mind going for the more modern choice main but it is not easy to update screenshots and videos to match, and it is incompatible with other CS2103 materials e.g., iP, tP, lecture videos. The other option is to switch everything in Git-Mastery to master (at least the parts facing students). How much work is that?

@jovnc
Copy link
Collaborator Author

jovnc commented Dec 15, 2025

@damithc I remember it being discussed somewhere (though I cannot trace the exact issue), that it was decided that main was the default branch for git-mastery.

But, given the constraints, I think it could be possible to switch everything to master.

Regarding effort needed, we would need to:

  • update all download.py for exercises if it uses main
  • update all hands on that uses main
  • update git-mastery website (as some hands on uses main, some exercises uses master, so effort is needed to update the website if we want to standardise to one)
  • update repo-smith to default to master

Alternatively, we can keep what we have currently at the cost of some (technical) debt. This means for example, in this exercise, we cannot assume main or master as default branch and must check both. This is the fastest solution, but would require some clarification with students early in the course, that default branch can either be main or master

@VikramGoyal23 @woojiahao What are your thoughts on this?

@VikramGoyal23
Copy link
Collaborator

@damithc I remember it being discussed somewhere (though I cannot trace the exact issue), that it was decided that main was the default branch for git-mastery.

But, given the constraints, I think it could be possible to switch everything to master.

Regarding effort needed, we would need to:

* update all `download.py` for exercises if it uses `main`

* update all hands on that uses `main`

* update git-mastery website (as some hands on uses `main`, some exercises uses `master`, so effort is needed to update the website if we want to standardise to one)

* update repo-smith to default to `master`

Alternatively, we can keep what we have currently at the cost of some (technical) debt. This means for example, in this exercise, we cannot assume main or master as default branch and must check both. This is the fastest solution, but would require some clarification with students early in the course, that default branch can either be main or master

@VikramGoyal23 @woojiahao What are your thoughts on this?

Yes, I discussed this issue in git-mastery/git-mastery#49. During an in-person discussion, Damith mentioned the value of using both interchangeably to get students familiarized with different default branches. Certainly, we can try to fully commit to one branch or the other, but either would require much effort- main is the assumed branch for the majority of the exercise infrastructure, while master is more in-line with the course contents. I think the middle-of-the-road option would be the least painful in the long run, especially since we would have to clarify the possibility of different default branches to the students anyhow to prepare them for the real world.

@jovnc jovnc marked this pull request as ready for review December 18, 2025 16:09
@VikramGoyal23 VikramGoyal23 self-requested a review December 23, 2025 12:18
@VikramGoyal23
Copy link
Collaborator

@jovnc Can you uncomment all the unit tests and run them? I can give a proper review once that's done.

@jovnc
Copy link
Collaborator Author

jovnc commented Dec 23, 2025

@VikramGoyal23 Had to make some major changes to the tests and verify logic, as I realised some limitations in the existing verify logic (as I can only verify the end state, and not the in between state for each task).

Copy link
Collaborator

@VikramGoyal23 VikramGoyal23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just need to update the branch logic and it can be merged.

Comment on lines +64 to +74
comments: str = []
if len(unstaged_files) != 4 or not all(
file in unstaged_files
for file in ["east.csv", "north.csv", "south.csv", "west.csv"]
):
comments.append(WRONG_FILES_IN_WORKING_DIRECTORY)

if len(staged_files) != 3 or not all(
file in staged_files for file in ["east.csv", "north.csv", "south.csv"]
):
comments.append(WRONG_FILES_IN_STAGING_AREA)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I initially thought that this logic could be easily circumvented by choosing a set of incorrect commits to reset to, such a set of commits (other than the one mentioned in the exercise instructions) does not exist, making this logic sound in all cases.

Copy link
Collaborator

@VikramGoyal23 VikramGoyal23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive me, I forgot to write down one more small nit I had.

Comment on lines +59 to +61
if "Record data for Jan 12" in commit_messages:
raise exercise.wrong_answer([CONTAINS_TASK_THREE_COMMIT])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we explicitly check that the head is at January 11th after this for extra safety?

@jovnc
Copy link
Collaborator Author

jovnc commented Dec 24, 2025

@VikramGoyal23 I have made the changes, thanks!



def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
branch = exercise.repo.branches.branch_or_none("main")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we don't need branch_or_none but it's fine to keep here.

Copy link
Collaborator

@VikramGoyal23 VikramGoyal23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@VikramGoyal23 VikramGoyal23 merged commit 086fffb into git-mastery:main Dec 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Exercise Discussion] T4L5 Rewriting History to Start Over

3 participants