mirror of https://github.com/zulip/zulip.git
Fix post-receive hook's API postings.
(imported from commit 98021d3ee5e84b533e17ec741538be60925b4e87)
This commit is contained in:
parent
d5d3694451
commit
e53dbbd756
|
@ -19,9 +19,23 @@ 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)
|
||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
verbose=False)
|
||||
|
||||
def check_output(*popenargs, **kwargs):
|
||||
if 'stdout' in kwargs:
|
||||
raise ValueError('stdout argument not allowed, it will be overridden.')
|
||||
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
|
||||
output, unused_err = process.communicate()
|
||||
retcode = process.poll()
|
||||
if retcode:
|
||||
cmd = kwargs.get("args")
|
||||
if cmd is None:
|
||||
cmd = popenargs[0]
|
||||
raise subprocess.CalledProcessError(retcode, cmd, output=output)
|
||||
return output
|
||||
|
||||
subprocess.check_output = check_output
|
||||
|
||||
args = sys.stdin.read()
|
||||
oldrev, newrev, refname = args.split()
|
||||
|
@ -30,12 +44,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)])
|
||||
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,
|
||||
"content": "The following commits were just pushed to %s:\n\n" % (refname.replace("refs/heads/", ""),) + commits,
|
||||
"recipient": "tabbott@humbughq.com",
|
||||
}
|
||||
client.send_message(message_data)
|
||||
|
|
Loading…
Reference in New Issue