Created
November 22, 2015 07:20
-
-
Save DeepSpawn/7334e5dd6588ca58d7b5 to your computer and use it in GitHub Desktop.
This file contains 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] | |
issue_key_regex = "([A-Z][A-Z]+-\d+)" | |
branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() | |
issue_key_match = re.match(issue_key_regex, branch) | |
if issue_key_match: | |
issue_key = issue_key_match.group(0) | |
with open(commit_msg_filepath, 'r+') as f: | |
content = f.read() | |
f.seek(0) | |
f.write("%s: \n%s" % (issue_key,content)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment