From 84d87ecb9871d1936c7cbf6e102e40004bdaa325 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 28 Nov 2019 15:52:49 +0100 Subject: [PATCH] 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 --- distgit_bugzilla_sync/script.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index e106941..0b310a4 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -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"):