Merge ~ubuntu-release/britney/+git/britney2-ubuntu:email-direct-upload-sponsor into ~ubuntu-release/britney/+git/britney2-ubuntu:master

Proposed by Iain Lane
Status: Merged
Merged at revision: 7cc72bf2d65dcd609539ac89ae8d19f55e37e1dd
Proposed branch: ~ubuntu-release/britney/+git/britney2-ubuntu:email-direct-upload-sponsor
Merge into: ~ubuntu-release/britney/+git/britney2-ubuntu:master
Diff against target: 37 lines (+9/-1)
2 files modified
britney2/policies/email.py (+8/-1)
tests/test_email.py (+1/-0)
Reviewer Review Type Date Requested Status
Robert Bruce Park Pending
Ubuntu Release Team Pending
Review via email: mp+319448@code.launchpad.net

Description of the change

I noticed that the testsuite for a sponsored direct upload emails the sponsor only.

I think it should email both the sponsor and the sponsoree. This change fixes that and doesn't regress any of the other testcases - could you see if it's sane please?

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

(some comments inline)

A cleaner-looking and faster solution would be:

people = {
         source['package_signer_link'],
         source['sponsor_link'],
         source['creator_link'],
} - {None} - BOTS
bileto = source['package_signer_link'] in BOTS
regular = not source['creator_link'] and not source['sponsor_link']
if bileto or regular:
    people.add(source['package_creator_link'])
return people

Revision history for this message
Iain Lane (laney) wrote :

Thanks - I didn't know that nested functions are bad for performance if called a lot. I'll eliminate those. I don't necessarily agree that it's clearer, but I'll fix it as you suggest.

Revision history for this message
Iain Lane (laney) :
Revision history for this message
Iain Lane (laney) wrote :

I fixed the comments and merged a while ago, sorry for forgetting to close this MP

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/britney2/policies/email.py b/britney2/policies/email.py
2index b612bb7..50c8e86 100644
3--- a/britney2/policies/email.py
4+++ b/britney2/policies/email.py
5@@ -38,12 +38,19 @@ If you have any questions about this email, please ask them in #ubuntu-release c
6
7 def person_chooser(source):
8 """Assign blame for the current source package."""
9+ def should_add_package_creator():
10+ # things which were copied into unstable by a known bot
11+ bot = source['package_signer_link'] in BOTS
12+ # direct uploads
13+ regular = not source['creator_link'] and not source['sponsor_link']
14+ return bot or regular
15+
16 people = {
17 source['package_signer_link'],
18 source['sponsor_link'],
19 source['creator_link'],
20 } - {None} - BOTS
21- if source['package_signer_link'] in BOTS:
22+ if should_add_package_creator():
23 people.add(source['package_creator_link'])
24 return people
25
26diff --git a/tests/test_email.py b/tests/test_email.py
27index a9ae1a3..fa398e4 100755
28--- a/tests/test_email.py
29+++ b/tests/test_email.py
30@@ -127,6 +127,7 @@ class T(unittest.TestCase):
31 })
32 self.assertEqual(person_chooser(SPONSORED_UPLOAD), {
33 'https://api.launchpad.net/1.0/~apw',
34+ 'https://api.launchpad.net/1.0/~smb'
35 })
36 self.assertEqual(person_chooser(BILETO), {
37 'https://api.launchpad.net/1.0/~dobey',

Subscribers

People subscribed via source and target branches