Merge lp:~cjwatson/launchpad/close-account-code-import into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18957
Proposed branch: lp:~cjwatson/launchpad/close-account-code-import
Merge into: lp:launchpad
Diff against target: 125 lines (+38/-5)
3 files modified
lib/lp/registry/scripts/closeaccount.py (+12/-0)
lib/lp/registry/scripts/tests/test_closeaccount.py (+21/-0)
lib/lp/testing/factory.py (+5/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-code-import
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+366916@code.launchpad.net

Commit message

Skip code import references in close-account.

Description of the change

Code imports don't inherently contain any personal information about the person who created them.

I also skipped RevisionAuthor.person for now. This isn't great, and there's a bug reference, but we can otherwise be basically stuck if a person ever pushed a branch to Launchpad even though the amount of personal information retained is quite scant.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/closeaccount.py'
2--- lib/lp/registry/scripts/closeaccount.py 2019-05-02 17:36:15 +0000
3+++ lib/lp/registry/scripts/closeaccount.py 2019-05-03 12:20:18 +0000
4@@ -91,9 +91,11 @@
5 ('accessartifactgrant', 'grantor'),
6 ('accesspolicygrant', 'grantor'),
7 ('binarypackagepublishinghistory', 'removed_by'),
8+ ('branch', 'registrant'),
9 ('branchmergeproposal', 'merge_reporter'),
10 ('branchmergeproposal', 'merger'),
11 ('branchmergeproposal', 'queuer'),
12+ ('branchmergeproposal', 'registrant'),
13 ('branchmergeproposal', 'reviewer'),
14 ('branchsubscription', 'subscribed_by'),
15 ('bug', 'owner'),
16@@ -103,10 +105,14 @@
17 ('bugnomination', 'owner'),
18 ('bugtask', 'owner'),
19 ('bugsubscription', 'subscribed_by'),
20+ ('codeimport', 'owner'),
21+ ('codeimport', 'registrant'),
22+ ('codeimportevent', 'person'),
23 ('faq', 'last_updated_by'),
24 ('featureflagchangelogentry', 'person'),
25 ('gitactivity', 'changee'),
26 ('gitactivity', 'changer'),
27+ ('gitrepository', 'registrant'),
28 ('gitrule', 'creator'),
29 ('gitrulegrant', 'grantor'),
30 ('gitsubscription', 'subscribed_by'),
31@@ -156,6 +162,12 @@
32 # This is maintained by trigger functions and a garbo job. It
33 # doesn't need to be updated immediately.
34 ('bugsummary', 'viewed_by'),
35+
36+ # XXX cjwatson 2019-05-02 bug=1827399: This is suboptimal because it
37+ # does retain some personal information, but it's currently hard to
38+ # deal with due to the size and complexity of references to it. We
39+ # can hopefully provide a garbo job for this eventually.
40+ ('revisionauthor', 'person'),
41 }
42 reference_names = {
43 (src_tab, src_col) for src_tab, src_col, _, _, _, _ in references}
44
45=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
46--- lib/lp/registry/scripts/tests/test_closeaccount.py 2019-05-02 17:36:15 +0000
47+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2019-05-03 12:20:18 +0000
48@@ -23,6 +23,8 @@
49 from lp.app.enums import InformationType
50 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
51 from lp.bugs.model.bugsummary import BugSummary
52+from lp.code.enums import TargetRevisionControlSystems
53+from lp.code.tests.helpers import GitHostingFixture
54 from lp.hardwaredb.interfaces.hwdb import (
55 HWBus,
56 IHWDeviceSet,
57@@ -491,3 +493,22 @@
58 self.runScript(script)
59 self.assertRemoved(account_id, person_id)
60 self.assertEqual(person, product.owner)
61+
62+ def test_skips_code_import(self):
63+ self.useFixture(GitHostingFixture())
64+ person = self.factory.makePerson()
65+ team = self.factory.makeTeam(members=[person])
66+ code_imports = [
67+ self.factory.makeCodeImport(
68+ registrant=person, target_rcs_type=target_rcs_type, owner=team)
69+ for target_rcs_type in (
70+ TargetRevisionControlSystems.BZR,
71+ TargetRevisionControlSystems.GIT)]
72+ person_id = person.id
73+ account_id = person.account.id
74+ script = self.makeScript([six.ensure_str(person.name)])
75+ with dbuser('launchpad'):
76+ self.runScript(script)
77+ self.assertRemoved(account_id, person_id)
78+ self.assertEqual(person, code_imports[0].registrant)
79+ self.assertEqual(person, code_imports[1].registrant)
80
81=== modified file 'lib/lp/testing/factory.py'
82--- lib/lp/testing/factory.py 2019-02-07 15:04:13 +0000
83+++ lib/lp/testing/factory.py 2019-05-03 12:20:18 +0000
84@@ -2408,7 +2408,7 @@
85 git_repo_url=None,
86 bzr_branch_url=None, registrant=None,
87 rcs_type=None, target_rcs_type=None,
88- review_status=None):
89+ review_status=None, owner=None):
90 """Create and return a new, arbitrary code import.
91
92 The type of code import will be inferred from the source details
93@@ -2439,20 +2439,20 @@
94 registrant, context, branch_name,
95 rcs_type=RevisionControlSystems.BZR_SVN,
96 target_rcs_type=target_rcs_type,
97- url=svn_branch_url, review_status=review_status)
98+ url=svn_branch_url, review_status=review_status, owner=owner)
99 elif git_repo_url is not None:
100 assert rcs_type in (None, RevisionControlSystems.GIT)
101 return code_import_set.new(
102 registrant, context, branch_name,
103 rcs_type=RevisionControlSystems.GIT,
104 target_rcs_type=target_rcs_type,
105- url=git_repo_url, review_status=review_status)
106+ url=git_repo_url, review_status=review_status, owner=owner)
107 elif bzr_branch_url is not None:
108 return code_import_set.new(
109 registrant, context, branch_name,
110 rcs_type=RevisionControlSystems.BZR,
111 target_rcs_type=target_rcs_type,
112- url=bzr_branch_url, review_status=review_status)
113+ url=bzr_branch_url, review_status=review_status, owner=owner)
114 else:
115 assert rcs_type in (None, RevisionControlSystems.CVS)
116 return code_import_set.new(
117@@ -2460,7 +2460,7 @@
118 rcs_type=RevisionControlSystems.CVS,
119 target_rcs_type=target_rcs_type,
120 cvs_root=cvs_root, cvs_module=cvs_module,
121- review_status=review_status)
122+ review_status=review_status, owner=owner)
123
124 def makeChangelog(self, spn=None, versions=[]):
125 """Create and return a LFA of a valid Debian-style changelog.