Skip to content

Instantly share code, notes, and snippets.

@alisaifee
Created April 6, 2013 06:27
Show Gist options
  • Save alisaifee/5325119 to your computer and use it in GitHub Desktop.
Save alisaifee/5325119 to your computer and use it in GitHub Desktop.
post-checkout script to print the jira summary for the branch you're on if its named with a jira or the summary of the jira of the last commit on that branch.
#!/usr/bin/python
import os
import sys
import re
branch_name = os.popen("git svn info | grep URL | awk -F '/' '{print $NF}'").read()
expr = re.compile("([A-Z]+-[0-9]+)")
if expr.findall(branch_name):
jira = expr.findall(branch_name)[0]
os.system("jira-cli --oneline %s" % jira)
else:
last_commit = os.popen("git log -n 1 --format='%s'").read()
if expr.findall(last_commit):
jira = expr.findall(last_commit)[0]
os.system("jira-cli --oneline %s" % jira)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment