Created
September 17, 2014 23:16
-
-
Save evhen14/428d98b7cb1c388715e4 to your computer and use it in GitHub Desktop.
update script for commit message format validation on Git server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys,os,re | |
| refname = sys.argv[1] | |
| oldmsg = sys.argv[2] | |
| newmsg = sys.argv[3] | |
| def check_message_format(): | |
| print "Ref name: ", refname | |
| print "Old msgision: ", oldmsg | |
| print "New msgision: ", newmsg | |
| command = """git log --pretty=format:"%s" """ + oldmsg + ".." + newmsg | |
| msgCursor = os.popen(command) | |
| for msg in msgCursor: | |
| match = re.match("^(((Revert \")*[A-Z]{2,4}-[0-9]{1,6}(\:)?[ ])|(Merge))", msg.strip()) | |
| if not match: | |
| print "Message format check failed. Message: " + msg | |
| print "Supported formats are:" | |
| print " UI-123: Making it finally work" | |
| print " UI-123 Fixing previous commit" | |
| print " Merge master/rubbish" | |
| sys.exit(13) | |
| msgCursor.close() | |
| check_message_format() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment