Page MenuHomePhabricator

Mercurial - Client-side enforce commit messages start with a Task #

Authored By
cspeckmim
May 5 2017, 2:36 PM
Size
829 B
Referenced Files
None
Subscribers
None

Mercurial - Client-side enforce commit messages start with a Task #

import re
def enforce_commitmsg(ui, repo, hooktype, node=None, source=None, parent1=None, parent2=None, *args, **kwargs):
cmt = repo[node]
msg = cmt.description()
lower_msg = msg.lower()
if len(cmt.parents()) > 1 or lower_msg.startswith('backed out ') or lower_msg.startswith('back out') or lower_msg.startswith('backout'):
print "Merge or Backout - not enforcing commit message"
return None
task_re = re.compile("^(Task-|Task - |Task -|Task #|Task |Task # |#)([0-9]{1,5}).+?\s*", re.IGNORECASE)
if task_re.match(msg):
print "Legit-type commit for #%s" % task_re.match(msg).group(2)
return None
print
print
print "Your commit message '%s' does not have proper Task ID."
print "Please try again with a legit message."
print
print
return True

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
641499
Default Alt Text
Mercurial - Client-side enforce commit messages start with a Task # (829 B)

Event Timeline