diff --git a/zerver/tests.py b/zerver/tests.py index 13cc35c282..33d9e2e50f 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -4091,8 +4091,8 @@ class StashHookTests(AuthedTestCase): content_type="application/x-www-form-urlencoded", **self.api_auth(email)) - self.assertEqual(msg.subject, u"Secret project/Operation unicorn") - self.assertEqual(msg.content, """`f259e90` was pushed to **Secret project/Operation unicorn** with: + self.assertEqual(msg.subject, u"Secret project/Operation unicorn: master") + self.assertEqual(msg.content, """`f259e90` was pushed to **master** in **Secret project/Operation unicorn** with: * `f259e90`: Updating poms ...""") diff --git a/zerver/views/webhooks.py b/zerver/views/webhooks.py index c084b424bc..e74c3661b5 100644 --- a/zerver/views/webhooks.py +++ b/zerver/views/webhooks.py @@ -559,6 +559,7 @@ def api_stash_webhook(request, user_profile, stream=REQ(default='')): try: repo_name = payload["repository"]["name"] project_name = payload["repository"]["project"]["name"] + branch_name = payload["refChanges"][0]["refId"].split("/")[-1] commit_entries = payload["changesets"]["values"] commits = [(entry["toCommit"]["displayId"], entry["toCommit"]["message"].split("\n")[0]) for \ @@ -572,9 +573,10 @@ def api_stash_webhook(request, user_profile, stream=REQ(default='')): except (AttributeError, KeyError): stream = 'commits' - subject = "%s/%s" % (project_name, repo_name) + subject = "%s/%s: %s" % (project_name, repo_name, branch_name) - content = "`%s` was pushed to **%s** with:\n\n" % (head_ref, subject) + content = "`%s` was pushed to **%s** in **%s/%s** with:\n\n" % ( + head_ref, branch_name, project_name, repo_name) content += "\n".join("* `%s`: %s" % ( commit[0], commit[1]) for commit in commits)