Last Updated: February 25, 2016
·
1.107K
· Lorin Hochstein

New git flow branch from Trello card URL

I like to name my git-flow feature branches after the associated Trello card. When I copy a trello URL to the clipboard (e.g., https://trello.com/c/AbcDEfG/name-of-card) and type gffs at the prompt, TextExpander will replace the text with:

$ git flow feature start AbcDEfG/name-of-card

To do this, I define a TextExpander snippet that contains the following script:

#!/usr/bin/env python

import richxerox
import re
import subprocess
import sys

url = richxerox.paste()
x = re.match('https://trello.com/c/(.*)', url)
if x is not None:
    sys.stdout.write("git flow feature start {}".format(x.group(1)))
else:
    subprocess.call(["/usr/bin/say", "Clipboard does not contain a Trello card url"])
#%-