integration: add branch name to Stash messages.

(imported from commit 3421717acd0e85cb2a1b1f0bd15438f70fd3d82e)
This commit is contained in:
Jessica McKellar 2013-10-30 13:54:54 -04:00
parent 8ec2fd0908
commit 35e764e7d1
2 changed files with 6 additions and 4 deletions

View File

@ -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 ...""")

View File

@ -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)