mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 16:43:57 +00:00
Fixup 'force pushed' message when creating branches in Github
Github flags pushes as either `forced` or not. However, it always marks new branches as forced pushes--but we don't necessarily agree with them. This commit checks for the `created` flag as well. This resolves Trac #2346 (imported from commit 960bd3ad707a4d1ad431e21dcd79389e8d4b297b)
This commit is contained in:
@@ -116,7 +116,8 @@ def api_github_v2(user_profile, event, payload, branches, default_stream, commit
|
||||
payload['before'], payload['after'],
|
||||
payload['compare'],
|
||||
payload['pusher']['name'],
|
||||
forced=payload['forced'])
|
||||
forced=payload['forced'],
|
||||
created=payload['created'])
|
||||
elif event == 'commit_comment':
|
||||
comment = payload['comment']
|
||||
subject = "%s: commit %s" % (topic_focus, comment['commit_id'])
|
||||
@@ -255,14 +256,15 @@ def build_commit_list_content(commits, branch, compare_url, pusher):
|
||||
|
||||
return content
|
||||
|
||||
def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=None):
|
||||
def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=None, created=None):
|
||||
short_ref = re.sub(r'^refs/heads/', '', ref)
|
||||
subject = name
|
||||
|
||||
if re.match(r'^0+$', after):
|
||||
content = "%s deleted branch %s" % (pusher,
|
||||
short_ref)
|
||||
elif forced or (forced is None and len(commits) == 0):
|
||||
# 'created' and 'forced' are github flags; the second check is for beanstalk
|
||||
elif (forced and not created) or (forced is None and len(commits) == 0):
|
||||
content = ("%s [force pushed](%s) to branch %s. Head is now %s"
|
||||
% (pusher,
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user