-
Notifications
You must be signed in to change notification settings - Fork 25
Implement exercise T6L2/merge-squash #148
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
There seems to be some issue with the squash option for the merge step in repo-smith
|
This pull request is not yet complete, the testing needs to be cleaned up. |
jovnc
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.
LGTM, tests looks comprehensive enough, some minor changes needed on verification process before merging.
merge_squash/verify.py
Outdated
|
|
||
| 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] |
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 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
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.
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.
|
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
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.
I think that we could be safer with more tests, and the verification logic can be improved
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.
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]): |
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.
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]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.
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: |
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 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.
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.
git switch supporting
git merge --squash main
git commit -m "test"
Exercise Review
Exercise Discussion
#68
Checklist
Git-Masteryorganization, have you created a request for it?repo-smithto validate the exercise grading scheme?test-download.sh?git-autograder?app?