我需要简单的 mercurial 钩子来使用模式检查提交评论。这是我的钩子:
#!/usr/bin/env python
#
# save as .hg/check_whitespace.py and make executable
import re
def check_comment(comment):
#
print 'Checking comment...'
pattern = '^((Issue \d+:)|(No Issue:)).+'
if re.match(pattern, comment, flags=re.IGNORECASE):
return 1
else:
print >> sys.stderr, 'Comment does not match pattern. You must start it with "Issue 12323:" or "No Issue:"'
return 0
if __name__ == '__main__':
import os, sys
comment=os.popen('hg tip --template "{desc}"').read()
if not check_comment(comment):
sys.exit(1)
sys.exit(0)
有用。'Comment does not match pattern. You must start it with "Issue 12323:" or "No Issue:"'
当我从控制台提交时,它甚至会显示错误消息。但是当我尝试从 Tortoise Hg Workbench 提交时,只显示系统消息:abort: pretxncommit.check_comment hook exited with status 1
.
我需要通知用户出了什么问题。有什么办法可以强制 Tortoise Hg 显示钩子的输出?