Last active
August 29, 2015 14:00
t-?([0-9]+) なブランチでコミットするとコミットメッセージに Trello-{num} とかカードに対する URL とかを付けてくれるやつ。 git config で trello.baseurl の設定が必要
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 re | |
from subprocess import Popen, PIPE | |
import sys | |
COMMIT_EDITMSG = sys.argv[1] | |
branch = Popen(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout=PIPE).stdout.read().strip() | |
matched = re.search('t-?([0-9]+)', branch) | |
if not matched: | |
sys.exit(0) | |
base_url = Popen(['git', 'config', '--get', 'trello.baseurl'], stdout=PIPE).stdout.read().strip() | |
template = open(COMMIT_EDITMSG, 'r').read() | |
fh = open(COMMIT_EDITMSG, 'w') | |
fh.write('(Trello-{0})\n\nTrello: {1}/{0}\n{2}'.format(matched.group(1), base_url, template)) |
t-?([0-9]+) だと短縮 URL に引っかけられない (ボードの ID から導き出せると思ったけど無理っぽい) ので t-([a-zA-Z0-9]+)- で行こうと思うよ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
うおー Python 2.6 で subprocess.check_output() 動かないうおー