mirror of https://github.com/zulip/zulip.git
github_webhook: extract the constants to the top of the file.
This commit is contained in:
parent
84e23dd015
commit
e1079d8475
|
@ -9,6 +9,9 @@ import logging
|
||||||
import re
|
import re
|
||||||
import ujson
|
import ujson
|
||||||
|
|
||||||
|
COMMITS_IN_LIST_LIMIT = 10
|
||||||
|
ZULIP_TEST_REPO_NAME = 'zulip-test'
|
||||||
|
ZULIP_TEST_REPO_ID = 6893087
|
||||||
|
|
||||||
def github_generic_subject(noun, topic_focus, blob):
|
def github_generic_subject(noun, topic_focus, blob):
|
||||||
# issue and pull_request objects have the same fields we're interested in
|
# issue and pull_request objects have the same fields we're interested in
|
||||||
|
@ -136,7 +139,7 @@ def api_github_landing(request, user_profile, event=REQ,
|
||||||
|
|
||||||
# Special hook for capturing event data. If we see our special test repo, log the payload from github.
|
# Special hook for capturing event data. If we see our special test repo, log the payload from github.
|
||||||
try:
|
try:
|
||||||
if repository['name'] == 'zulip-test' and repository['id'] == 6893087 and settings.PRODUCTION:
|
if repository['name'] == ZULIP_TEST_REPO_NAME and repository['id'] == ZULIP_TEST_REPO_ID and settings.PRODUCTION:
|
||||||
with open('/var/log/zulip/github-payloads', 'a') as f:
|
with open('/var/log/zulip/github-payloads', 'a') as f:
|
||||||
f.write(ujson.dumps({'event': event,
|
f.write(ujson.dumps({'event': event,
|
||||||
'payload': payload,
|
'payload': payload,
|
||||||
|
@ -211,16 +214,15 @@ def build_commit_list_content(commits, branch, compare_url, pusher):
|
||||||
push_text,
|
push_text,
|
||||||
branch))
|
branch))
|
||||||
num_commits = len(commits)
|
num_commits = len(commits)
|
||||||
max_commits = 10
|
truncated_commits = commits[:COMMITS_IN_LIST_LIMIT]
|
||||||
truncated_commits = commits[:max_commits]
|
|
||||||
for commit in truncated_commits:
|
for commit in truncated_commits:
|
||||||
short_id = commit['id'][:7]
|
short_id = commit['id'][:7]
|
||||||
(short_commit_msg, _, _) = commit['message'].partition("\n")
|
(short_commit_msg, _, _) = commit['message'].partition("\n")
|
||||||
content += "* [%s](%s): %s\n" % (short_id, commit['url'],
|
content += "* [%s](%s): %s\n" % (short_id, commit['url'],
|
||||||
short_commit_msg)
|
short_commit_msg)
|
||||||
if (num_commits > max_commits):
|
if (num_commits > COMMITS_IN_LIST_LIMIT):
|
||||||
content += ("\n[and %d more commits]"
|
content += ("\n[and %d more commits]"
|
||||||
% (num_commits - max_commits,))
|
% (num_commits - COMMITS_IN_LIST_LIMIT,))
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue