패턴을 사용하여 커밋 확인을 확인하는 수은 용 간단한 후크가 필요합니다. 여기 내 후크입니다 :Tortoise Hg 로그 창에서 후크 출력을 표시하는 방법은 무엇입니까?
#!/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에게 훅의 출력을 보여줄 수있는 방법이 있습니까?
그냥 추측하지만 sys.err 대신 sys.out에 글을 써 보았습니까? – bbaja42
예. 도움이되지 않았다. –