Skip to content

Conversation

@VikramGoyal23
Copy link
Collaborator

@VikramGoyal23 VikramGoyal23 commented Dec 10, 2025

Exercise Review

Exercise Discussion

#68

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?

There seems to be some issue with the squash
option for the merge step in repo-smith
@VikramGoyal23
Copy link
Collaborator Author

VikramGoyal23 commented Dec 10, 2025

This pull request is not yet complete, the testing needs to be cleaned up.

@VikramGoyal23 VikramGoyal23 requested a review from jovnc December 11, 2025 07:36
@jovnc jovnc linked an issue Dec 11, 2025 that may be closed by this pull request
1 task
Copy link
Collaborator

@jovnc jovnc left a comment

Choose a reason for hiding this comment

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

LGTM, tests looks comprehensive enough, some minor changes needed on verification process before merging.


commit_messages_in_main = [c.commit.message.strip() for c in main_branch.commits]

merge_commits = [c for c in main_branch.commits if len(c.parents) > 1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the logic here is that we want to ensure a linear history by ensuring that there are no commits with multiple parents (that can indicate a merge commit).

But I think that it is also possible to pass this verification using git -i rebase.

However, I'm not sure if there's a better way to verify squash merge, so this LGTM for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I was wary of using commit messages for verification purposes but I think it's best to check if the latest commit message has the word "Squash" to ensure a proper squash merge.

@VikramGoyal23
Copy link
Collaborator Author

I moved around some of the verification logic as well, since to me, it made more sense to check if the proper type of merge was used after checking if the changes were even present.

@jovnc jovnc added exercise review Review a proposed exercise discussing labels Dec 12, 2025
Copy link
Collaborator

@jovnc jovnc left a comment

Choose a reason for hiding this comment

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

I think that we could be safer with more tests, and the verification logic can be improved

Copy link
Collaborator

Choose a reason for hiding this comment

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

Update this to

See https://git-mastery.github.io/lessons/merge/exercise-merge-squash.html

commit_messages_in_main = [c.commit.message.strip() for c in main_branch.commits]
merge_commits = [c for c in main_branch.commits if len(c.parents) > 1]

if merge_commits or ("Squash" not in commit_messages_in_main[0]):
Copy link
Collaborator

Choose a reason for hiding this comment

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

There seems to be some type issue here from my linter

Can fix by typecasting above to string

commit_messages_in_main = [str(c.commit.message.strip()) for c in main_branch.commits]

Copy link
Collaborator

Choose a reason for hiding this comment

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

In addition, I don't think that we can verify it is a squash merge based on the commit message, as Squash doesn't appear in the commit message.

This is how I would solve this exercise

git merge --squash supporting
git commit -m "test" # I define my own squash commit message

)


def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that we need to consider the case where we squash merge the other way around as well, as I think that would be a common mistake.

ie. instead of squash merge from supporting to main, we squash merge main to supporting

We can add a test to verify the behaviour for this, and maybe have an error message for this as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

git switch supporting
git merge --squash main
git commit -m "test"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussing exercise review Review a proposed exercise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Exercise Discussion] T6L2/merge-squash

2 participants