Update post-receive hook to send messages via the API.

(imported from commit 81f4c9e55c44f19208c42d9a8e8db33ce44b02ac)
This commit is contained in:
Tim Abbott 2012-10-03 14:31:59 -04:00
parent 9b268e53ed
commit d5d3694451
2 changed files with 16 additions and 0 deletions

0
api/__init__.py Normal file
View File

View File

@ -16,6 +16,13 @@ import os
import sys import sys
import subprocess 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() args = sys.stdin.read()
oldrev, newrev, refname = args.split() 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", subprocess.check_call(["ssh", "app.humbughq.com", "--", "env", "-u", "GIT_DIR",
"/home/humbug/humbug/tools/update-deployment", "/home/humbug/humbug/tools/update-deployment",
oldrev, newrev, refname]) 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)