Merge lp:~abentley/launchpad/email-url-body into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 12119
Proposed branch: lp:~abentley/launchpad/email-url-body
Merge into: lp:launchpad
Diff against target: 272 lines (+79/-40)
5 files modified
lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt (+3/-1)
lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt (+3/-0)
lib/canonical/launchpad/emailtemplates/review-requested.txt (+3/-0)
lib/lp/code/doc/branch-merge-proposal-notifications.txt (+11/-4)
lib/lp/code/mail/tests/test_branchmergeproposal.py (+59/-35)
To merge this branch: bzr merge lp:~abentley/launchpad/email-url-body
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+43838@code.launchpad.net

Commit message

[r=bac][ui=none][bug=504080] Include merge proposal URL in email bodies.

Description of the change

= Summary =
Fix bug #50480: Please put the URL to the merge proposal in the body of the
email.

== Proposed fix ==
Insert the phrase "For more details, see:\n$URL" in all merge proposal emails.

== Pre-implementation notes ==
None

== Implementation details ==
Much lint was fixed, and some tests were rewritten so that they would fit in
the 78-character limit. The worst was in test_nominateReview_email_content,
where the only way to make the string respect the width limit was """\n""".

== Tests ==
bin/test -t mergeproposal -t merge-proposal

== Demo and Q/A ==
Create all kinds of emails:
1. create a proposal
2. change the values in a proposal
3. request a reviewer
4. make a comment

In all cases, the resulting email should say "For more details, see\n$URL".

= Launchpad lint =
(I don't think it makes sense to lint email templates...)

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt
  lib/canonical/launchpad/emailtemplates/review-requested.txt
  lib/lp/code/mail/tests/test_branchmergeproposal.py
  lib/lp/code/doc/branch-merge-proposal-notifications.txt
  lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt

./lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt
       1: Line exceeds 78 characters.
       6: Line has trailing whitespace.
./lib/canonical/launchpad/emailtemplates/review-requested.txt
       1: Line exceeds 78 characters.
       8: Line has trailing whitespace.
./lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt
       1: Line exceeds 78 characters.
       7: Line has trailing whitespace.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the bug fix and for the clean up Aaron. The branch looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt'
2--- lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt 2010-08-03 00:48:48 +0000
3+++ lib/canonical/launchpad/emailtemplates/branch-merge-proposal-created.txt 2010-12-15 22:11:41 +0000
4@@ -1,6 +1,8 @@
5 %(proposal_registrant)s has proposed merging %(source_branch)s into %(target_branch)s%(prerequisite)s.
6
7-%(reviews)s%(related_bugs)s%(gap)s%(comment)s
8+%(reviews)s%(related_bugs)s
9+For more details, see:
10+%(proposal_url)s%(gap)s%(comment)s
11 --
12 %(diff_cutoff_warning)s%(proposal_url)s
13 %(reason)s%(edit_subscription)s
14
15=== modified file 'lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt'
16--- lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt 2008-06-09 15:55:12 +0000
17+++ lib/canonical/launchpad/emailtemplates/branch-merge-proposal-updated.txt 2010-12-15 22:11:41 +0000
18@@ -1,6 +1,9 @@
19 The proposal to merge %(source_branch)s into %(target_branch)s has been updated.
20
21 %(delta)s
22+
23+For more details, see:
24+%(proposal_url)s
25 --
26 %(proposal_url)s
27 %(reason)s%(edit_subscription)s
28
29=== modified file 'lib/canonical/launchpad/emailtemplates/review-requested.txt'
30--- lib/canonical/launchpad/emailtemplates/review-requested.txt 2010-08-03 00:48:48 +0000
31+++ lib/canonical/launchpad/emailtemplates/review-requested.txt 2010-12-15 22:11:41 +0000
32@@ -1,5 +1,8 @@
33 You have been requested to review the proposed merge of %(source_branch)s into %(target_branch)s.
34
35+For more details, see:
36+%(proposal_url)s
37+
38 %(comment)s
39
40 --
41
42=== modified file 'lib/lp/code/doc/branch-merge-proposal-notifications.txt'
43--- lib/lp/code/doc/branch-merge-proposal-notifications.txt 2010-10-26 03:06:30 +0000
44+++ lib/lp/code/doc/branch-merge-proposal-notifications.txt 2010-12-15 22:11:41 +0000
45@@ -1,10 +1,12 @@
46-= Email Notifications for Branch Merge Proposals =
47+Email Notifications for Branch Merge Proposals
48+==============================================
49
50 Subscribers to any of the branches involved in the merge proposal get
51 notifications.
52
53
54-== Subscription ==
55+Subscription
56+------------
57
58 When subscribers subscribe to branches, they can specify what level of
59 notification they would like to receive.
60@@ -48,7 +50,8 @@
61 >>> source_owner = bmp.source_branch.owner
62
63
64-== Notification Recipients ==
65+Notification Recipients
66+-----------------------
67
68 Recipients are determined using getNotificationRecipients.
69
70@@ -88,7 +91,8 @@
71 You are subscribed to branch ...
72
73
74-== E-mail ==
75+E-mail
76+------
77
78 Jobs for notifications are automagically generated when the merge proposal
79 is created. When those jobs are run, the email is sent from the registrant.
80@@ -188,6 +192,9 @@
81 Bob the Builder (bob)
82 Mary Jones (mary): ui
83 <BLANKLINE>
84+ For more details, see:
85+ http://code.launchpad.dev/~person-name...
86+ <BLANKLINE>
87 This is the initial commit message.
88 <BLANKLINE>
89 It is included in the initial email sent out.
90
91=== modified file 'lib/lp/code/mail/tests/test_branchmergeproposal.py'
92--- lib/lp/code/mail/tests/test_branchmergeproposal.py 2010-12-01 11:26:57 +0000
93+++ lib/lp/code/mail/tests/test_branchmergeproposal.py 2010-12-15 22:11:41 +0000
94@@ -109,17 +109,24 @@
95 bmp.root_message_id = None
96 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
97 reviewer = bmp.target_branch.owner
98- self.assertEqual("""\
99-Baz Qux has proposed merging lp://dev/~bob/super-product/fix-foo-for-bar into lp://dev/~mary/super-product/bar.
100-
101-Requested reviews:
102- %s
103-
104---\x20
105-%s
106-%s
107-""" % (reviewer.unique_displayname, canonical_url(bmp),reason.getReason()),
108- ctrl.body)
109+ expected = dedent("""\
110+ Baz Qux has proposed merging %(source)s into %(target)s.
111+
112+ Requested reviews:
113+ %(reviewer)s
114+
115+ For more details, see:
116+ %(bmp)s
117+ --\x20
118+ %(bmp)s
119+ %(reason)s
120+ """) % {
121+ 'source': bmp.source_branch.bzr_identity,
122+ 'target': bmp.target_branch.bzr_identity,
123+ 'reviewer': reviewer.unique_displayname,
124+ 'bmp': canonical_url(bmp),
125+ 'reason': reason.getReason()}
126+ self.assertEqual(expected, ctrl.body)
127 self.assertEqual('[Merge] '
128 'lp://dev/~bob/super-product/fix-foo-for-bar into '
129 'lp://dev/~mary/super-product/bar', ctrl.subject)
130@@ -131,7 +138,7 @@
131 'Reply-To': bmp.address,
132 'Message-Id': '<foobar-example-com>'},
133 ctrl.headers)
134- self.assertEqual('Baz Qux <baz.qux@example.com>', ctrl.from_addr)
135+ self.assertEqual('Baz Qux <baz.qux@example.com>', ctrl.from_addr)
136 reviewer_id = mailer._format_user_address(reviewer)
137 self.assertEqual(set([reviewer_id, bmp.address]), set(ctrl.to_addrs))
138 mailer.sendAll()
139@@ -146,8 +153,7 @@
140 expected = (
141 'Related bugs:\n'
142 ' #%d I am a bug\n'
143- ' %s\n' % (bug.id, canonical_url(bug))
144- )
145+ ' %s\n' % (bug.id, canonical_url(bug)))
146 self.assertIn(expected, ctrl.body)
147
148 def test_forCreation_without_bugs(self):
149@@ -160,14 +166,16 @@
150 def test_forCreation_with_review_request(self):
151 """Correctly format list of reviewers."""
152 reviewer = self.factory.makePerson(name='review-person')
153- bmp, subscriber = self.makeProposalWithSubscriber(reviewer=reviewer)
154+ bmp, subscriber = self.makeProposalWithSubscriber(reviewer=reviewer)
155 bmp.nominateReviewer(reviewer, bmp.registrant, None)
156 mailer = BMPMailer.forCreation(bmp, bmp.registrant)
157 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
158 self.assertIn(
159 '\nRequested reviews:'
160- '\n Review-person (review-person)'
161- '\n\n-- \n',
162+ '\n Review-person (review-person)\n'
163+ '\n'
164+ 'For more details, see:\n'
165+ '%s\n-- \n' % canonical_url(bmp),
166 ctrl.body)
167
168 def test_forCreation_with_review_request_and_bug(self):
169@@ -175,7 +183,7 @@
170 reviewer = self.factory.makePerson(name='review-person')
171 bmp, subscriber = self.makeProposalWithSubscriber(reviewer=reviewer)
172 bug = self.factory.makeBug(title='I am a bug')
173- bmp.source_branch.linkBug(bug, bmp.registrant)
174+ bmp.source_branch.linkBug(bug, bmp.registrant)
175 bmp.nominateReviewer(reviewer, bmp.registrant, None)
176 mailer = BMPMailer.forCreation(bmp, bmp.registrant)
177 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
178@@ -184,7 +192,10 @@
179 '\n Review-person (review-person)'
180 '\nRelated bugs:'
181 '\n #%d I am a bug'
182- '\n %s\n\n--' % (bug.id, canonical_url(bug)))
183+ '\n %s\n'
184+ '\nFor more details, see:\n'
185+ '%s'
186+ '\n--' % (bug.id, canonical_url(bug), canonical_url(bmp)))
187 self.assertIn(expected, ctrl.body)
188
189 def test_forCreation_with_prerequisite_branch(self):
190@@ -303,7 +314,8 @@
191 self.assertEqual('inline; filename="review-diff.txt"',
192 attachment['Content-Disposition'])
193 self.assertEqual(diff_text[:25], attachment.get_payload(decode=True))
194- warning_text = "The attached diff has been truncated due to its size.\n"
195+ warning_text = (
196+ "The attached diff has been truncated due to its size.\n")
197 self.assertTrue(warning_text in ctrl.body)
198
199 def getProposalUpdatedEmailJob(self, merge_proposal):
200@@ -378,7 +390,7 @@
201 merge_proposal = self.factory.makeBranchMergeProposal()
202 mailer = BMPMailer.forModification(
203 merge_proposal, 'the diff', merge_proposal.registrant)
204- self.assertIsNot(None, mailer.message_id, 'message_id not set')
205+ self.assertIsNot(None, mailer.message_id, 'message_id not set')
206
207 def test_forModificationWithModificationTextDelta(self):
208 """Ensure the right delta is filled out if there is a change."""
209@@ -404,8 +416,9 @@
210 self.assertEqual('[Merge] '
211 'lp://dev/~bob/super-product/fix-foo-for-bar into\n\t'
212 'lp://dev/~mary/super-product/bar', email['subject'])
213+ bmp = job.branch_merge_proposal
214 expected = dedent("""\
215- The proposal to merge lp://dev/~bob/super-product/fix-foo-for-bar into lp://dev/~mary/super-product/bar has been updated.
216+ The proposal to merge %(source)s into %(target)s has been updated.
217
218 Commit Message changed to:
219
220@@ -414,10 +427,16 @@
221 Description changed to:
222
223 change description
224+
225+ For more details, see:
226+ %(bmp)s
227 --\x20
228- %s
229+ %(bmp)s
230 You are the owner of lp://dev/~bob/super-product/fix-foo-for-bar.
231- """) % canonical_url(job.branch_merge_proposal)
232+ """) % {
233+ 'source': bmp.source_branch.bzr_identity,
234+ 'target': bmp.target_branch.bzr_identity,
235+ 'bmp': canonical_url(bmp)}
236 self.assertEqual(expected, email.get_payload(decode=True))
237
238 def assertRecipientsMatches(self, recipients, mailer):
239@@ -531,17 +550,22 @@
240 review_request_job.run()
241 [sent_mail] = pop_notifications()
242 expected = dedent("""\
243- You have been requested to review the proposed merge of %(source)s into %(target)s.
244-
245- This branch is awesome.
246-
247- --
248- %(bmp)s
249- You are requested to review the proposed merge of %(source)s into %(target)s.
250- """ % {
251- 'source': bmp.source_branch.bzr_identity,
252- 'target': bmp.target_branch.bzr_identity,
253- 'bmp': canonical_url(bmp)})
254+ You have been requested to review the proposed merge of"""
255+ """ %(source)s into %(target)s.
256+
257+ For more details, see:
258+ %(bmp)s
259+
260+ This branch is awesome.
261+
262+ --\x20
263+ %(bmp)s
264+ You are requested to review the proposed merge of %(source)s"""
265+ """ into %(target)s.
266+ """ % {
267+ 'source': bmp.source_branch.bzr_identity,
268+ 'target': bmp.target_branch.bzr_identity,
269+ 'bmp': canonical_url(bmp)})
270 self.assertEqual(expected, sent_mail.get_payload(decode=True))
271
272 def test_nominateReview_emails_team_address(self):