Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
config.py*
.AppleDouble
webhook.log
.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------
Expand Down
9 changes: 5 additions & 4 deletions gitlab-commit-trello-comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down