Restrict Git commit message to certain pattern
For certain reason, some time you want your commit message to follow a standard pattern.
i.e. PJK-001: my message
Want to have a project code and assignment code there.
Now, open up your project git directory.
and edit commit-msg file (if doesn't exist, create it)
(NOTE: This example I'll write in Python)
message_file = sys.argv
message = open(message_file, 'r').read()
# Match with a specified pattern
match = re.match(r'PJK-(\d+):\ ', message)
if match is None:
print 'Your commit has been rejected!'
print 'Commit message must begin with \'PJK-(\d+): \''
print 'i.e. PJK-12: this is a commit message'
Simple right? But don't remember to change it to executable and no
$ chmod 755 /path/to/your/project/.git/hooks/commit-msg