diff --git a/.gitignore b/.gitignore index 8d6b743..6a63b24 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ config.py* .AppleDouble webhook.log +.idea diff --git a/README.md b/README.md index 2009cac..a41c057 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ Copy the config.py.sample to config.py and fill your gitlab and trello info. (2) create the gitlab webhook ----------------------------- -In gitlab, as admin, go to "Hooks" tab, create hook as: http://your.ip.goes.here:8000 +In gitlab, as admin, go to "Hooks" tab, create hook as: http://your.ip.goes.here:9000 -or change the port on line 175 of the script. +or change the port on line 113 of the script. (3) Optional init script ------------------------ diff --git a/gitlab-commit-trello-comment.py b/gitlab-commit-trello-comment.py index 22b96b9..a7ceced 100755 --- a/gitlab-commit-trello-comment.py +++ b/gitlab-commit-trello-comment.py @@ -87,22 +87,23 @@ def do_POST(self): namespace = (urlsplit(post['repository']['homepage'])[2]).split('/')[1] namespace = ''.join(('/', namespace)) if namespace else namespace repo_url = ''.join((config.gitlab_url, namespace, '/', repo)) - branch = re.split('/', post['ref'])[-1] + branch = re.findall('heads/(.+)', post['ref'])[0] branch_url = repo_url + '/commits/%s' % branch log.debug(pprint.pformat(post)) for commit in post['commits']: - card_short_id_list = map(int, re.findall('#([1-9]+)', commit['message'])) + card_short_id_list = map(int, re.findall('#([0-9]+)', commit['message'])) + log.debug(card_short_id_list); git_hash = commit['id'][:7] git_hash_url = repo_url + '/commit/%s' % git_hash author = commit['author']['name'] - comment = commit['message'] + comment = commit['message'].replace('#',':hash:') trello_comment = '''\[**%s** has a new commit about this card\] \[repo: [%s](%s) | branch: [%s](%s) | hash: [%s](%s)\] ---- %s''' % (author, repo, repo_url, branch, branch_url, git_hash, git_hash_url, comment) for card_short_id in card_short_id_list: - self.comment_to_trello(card_short_id, trello_comment) + self.comment_to_trello(card_short_id, trello_comment.encode('utf8')) def main(): """