Created
October 4, 2013 10:56
-
-
Save horimislime/6824225 to your computer and use it in GitHub Desktop.
Gitブランチに紐付いたRedmineチケット情報を表示する
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 | |
# -*- coding:utf-8 -*- | |
# | |
# pip install requests legit beautifulsoup | |
# | |
import re | |
import requests | |
from legit.scm import * | |
from BeautifulSoup import BeautifulSoup | |
base_url = 'http://redmine-domain.jp/redmine/issues/' | |
pattern = re.compile('[a-z]+\/([0-9]+)') | |
for branch in get_branches(): | |
m = pattern.search(branch.name) | |
title = None | |
if m: | |
url = base_url + m.group(1) | |
r = requests.get(url) | |
title = BeautifulSoup(r.text).title.text if r.status_code == 200 else None | |
print '%s (%s / %s)' % (branch.name, title, url) if title else branch.name | |
else: | |
print branch.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment