From 7390b6ec53e67323b54bf5e4773905ff2d0a398f Mon Sep 17 00:00:00 2001 From: acrefoot Date: Fri, 21 Feb 2014 12:15:15 -0500 Subject: [PATCH] Use 'forced' when available to determine if it's a force-push (imported from commit afbd1ed2efe2ce86ebd9639d514837211b7517b4) --- zerver/views/webhooks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zerver/views/webhooks.py b/zerver/views/webhooks.py index b93a5f414c..3c9295c780 100644 --- a/zerver/views/webhooks.py +++ b/zerver/views/webhooks.py @@ -115,7 +115,8 @@ def api_github_v2(user_profile, event, payload, branches, default_stream, commit payload['ref'], payload['commits'], payload['before'], payload['after'], payload['compare'], - payload['pusher']['name']) + payload['pusher']['name'], + forced=payload['forced']) elif event == 'commit_comment': comment = payload['comment'] subject = "%s: commit %s" % (topic_focus, comment['commit_id']) @@ -254,14 +255,14 @@ 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): +def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=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 len(commits) == 0: + elif forced or (forced is None and len(commits) == 0): content = ("%s [force pushed](%s) to branch %s. Head is now %s" % (pusher, url,