When updating bugs do not print email address if using --print-fas-names

For public display we do not want to share our user's email address more
than that. So we have an --print-fas-names action mapping back the email
to an username.
This commit makes the logic that updates open bugs when the default
assignee changes honor this flag.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2019-11-28 15:52:49 +01:00
parent 2fd1d0115d
commit 84d87ecb98

View file

@ -254,12 +254,14 @@ class BugzillaProxy:
bz_email = email_overrides.get(bz_email, bz_email)
return bz_email
def update_open_bugs(self, new_poc, prev_poc, product, name):
def update_open_bugs(self, new_poc, prev_poc, product, name, print_fas_names=False):
'''Change the package owner
:arg new_poc: email of the new point of contact.
:arg prev_poc: Username of the previous point of contact
:arg product: The product of the package to change in bugzilla
:arg name: Name of the package to change the owner.
:kwarg print_fas_names: Boolean specifying wether to print email or FAS names
(if these could be found).
'''
bz_query = {}
bz_query['product'] = product
@ -275,6 +277,16 @@ class BugzillaProxy:
for bug in query_results:
if bug.assigned_to == prev_poc and bug.assigned_to != new_poc:
if self.config["verbose"]:
old_poc = bug.assigned_to
if print_fas_names:
if old_poc in self.inverted_user_cache:
old_poc = self.inverted_user_cache[old_poc]
else:
old_poc = old_poc.split('@', 1)[0] + "@..."
if new_poc in self.inverted_user_cache:
new_poc = self.inverted_user_cache[new_poc]
else:
new_poc = newpoc.split('@', 1)[0] + "@..."
print(
f' - reassigning bug #{bug.bug_id} '
f'from {bug.assigned_to} to {new_poc}'
@ -435,6 +447,7 @@ class BugzillaProxy:
prev_poc=product[pkg_key]['initialowner'],
name=package,
product=bz_product_name,
print_fas_names=print_fas_names,
)
else:
if self.config.get("print-no-change"):