Closed camille-readbean closed 9 months ago
Good question @camille-readbean Let's wait to see if anyone can pitch in with anything relevant. The course itself does not provide any tool for this purpose, in the iP or the tP.
For our course, the standard is listed in https://nus-cs2103-ay2324s2.github.io/website/admin/standardsAndConventions.html#standards-conventions which directs to https://se-education.org/guides/conventions/git.html .
You can write a commit-msg
hook. See https://stackoverflow.com/questions/14151775/how-do-i-set-a-pattern-for-git-commit-messages for an example.
You'll need to write the script yourself though, I'm not aware of one that checks the conditions automatically for you.
Of course, some conditions are harder to check than others:
- Use the imperative mood in the subject line. (need a dictionary to know which word is imperative)
- Use blank lines to separate paragraphs. (how do you know where are the logical paragraphs?)
- Explain WHAT, WHY, not HOW. (literally needs an AI to check.)
Later on, the author of this GitHub issue/thread figured out that Intellij can checkstyle the commits. https://github.com/nus-cs2103-AY2324S2/forum/issues/278
Thanks!
I realised if theres an autograder that can auto detect git messages and check their subject, I wonder if we can (copy and) implement it client side to warn before commit as well
I realised if theres an autograder that can auto detect git messages and check their subject, I wonder if we can (copy and) implement it client side to warn before commit as well
FYI, our grading scripts clone all the iP repos and access Git commit information using GitPython library https://gitpython.readthedocs.io/en/stable/
The difference between the autograder and git hook is that the autograder is run periodically (and you need to leave it running or remember to invoke it once in a while), but hooks are invoked whenever you make a commit so you can't forget it.
Is there a way to enforce a standard on a git commit subject + message?