Created
October 24, 2018 11:23
-
-
Save Runman44/f1f6530e150bc55be6a0b5ef61cab5b7 to your computer and use it in GitHub Desktop.
git_hook_prefix_commit_msg
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, re | |
from subprocess import check_output | |
commit_msg_filepath = sys.argv[1] | |
branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() | |
regex = '(STRY.\d+)' | |
if re.search(regex, branch): | |
issue = re.search(regex, branch).group() | |
with open(commit_msg_filepath, 'r+') as fh: | |
commit_msg = fh.read() | |
fh.seek(0, 0) | |
fh.write('[%s] %s' % (issue, commit_msg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment