Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 23 lines (18 sloc) 579 Bytes
#!/usr/bin/env python
import sys
import json
import re
import urllib
from subprocess import call
if len(sys.argv) < 2:
sys.stderr.write("Bug number is required\n")
sys.exit(1)
BUG = sys.argv[1]
url = ('https://api-dev.bugzilla.mozilla.org/latest/bug/' + BUG +
'?include_fields=summary')
JSON = urllib.urlopen(url).read()
TITLE = json.loads(JSON)['summary']
parts = [BUG] + re.split(r"""[ -:,\'\"]+""", TITLE.lower())
parts = [part for part in parts if not ('[' in part or ']' in part)]
SLUG = '-'.join(parts[:4])
call("git checkout -b %s" % SLUG, shell=True)