From d5d36944510bd10bfa0de2a4b0098129bca5b308 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 3 Oct 2012 14:31:59 -0400 Subject: [PATCH] Update post-receive hook to send messages via the API. (imported from commit 81f4c9e55c44f19208c42d9a8e8db33ce44b02ac) --- api/__init__.py | 0 tools/post-receive | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 api/__init__.py diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/post-receive b/tools/post-receive index dda2ba4282..5ed8c8893e 100755 --- a/tools/post-receive +++ b/tools/post-receive @@ -16,6 +16,13 @@ import os import sys import subprocess +sys.path.append(os.path.dirname(os.path.dirname(os.readlink(__file__)))) +import api.common +client = api.common.HumbugAPI(email="humbug+commits@humbughq.com", + api_key=options.api_key, + verbose=False, + site=options.site) + args = sys.stdin.read() oldrev, newrev, refname = args.split() @@ -23,3 +30,12 @@ if refname in ["refs/heads/master", "refs/heads/test-post-receive"]: subprocess.check_call(["ssh", "app.humbughq.com", "--", "env", "-u", "GIT_DIR", "/home/humbug/humbug/tools/update-deployment", oldrev, newrev, refname]) + commits = subprocess.check_output(["git", "log", "--pretty=%s", "%s..%s" % (oldrev, newrev)]) + message_data = { + "type": "class", + "class": "devel", + "instance": "commits", + "content": "Commit %s pushed to %s! Commits include:\n" % (newrev, refname) + commits, + "recipient": "tabbott@humbughq.com", + } + client.send_message(message_data)