From bce634b19963cb19a28ebbeb6dd68764f98efd59 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 21 Nov 2019 09:57:16 +0100 Subject: [PATCH] Bring back the possibility to override the default assignee This is doable for packages that are retired (and thus where the assignee is orphan) as well as per product: Fedora vs Fedora EPEL being the most common. Signed-off-by: Pierre-Yves Chibon --- distgit_bugzilla_sync/script.py | 45 +++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index 68629a4..093d99b 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -358,21 +358,6 @@ def send_email(fromAddress, toAddress, subject, message, ccAddress=None): smtp.quit() -@cache.cache_on_arguments() -def _get_override_yaml(project, session): - pagure_override_url = '{0}/{1}/raw/master/f/{2}/{3}'.format( - env['pagure_url'].rstrip('/'), env['bugzilla']['override_repo'], project['namespace'], - project['name']) - - if config["verbose"]: - print('Querying {0}'.format(pagure_override_url)) - override_rv = session.get(pagure_override_url, timeout=30) - if override_rv.status_code == 200: - override_yaml = yaml.safe_load(override_rv.text) - return override_yaml.get('bugzilla_contact', {}) - return {} - - def _get_pdc_branches(session, repo): """ Gets the branches on a project. This function is used for mapping. @@ -585,6 +570,23 @@ class DistgitBugzillaSync: self.pagure_projects[idx] = project + @cache.cache_on_arguments() + def _get_override_yaml(self, project, session): + pagure_override_url = '{0}/{1}/raw/master/f/{2}/{3}'.format( + self.env['pagure_url'].rstrip('/'), + self.env['bugzilla']['override_repo'], + project['namespace'], + project['name'], + ) + + if self.env["verbose"]: + print('Querying {0}'.format(pagure_override_url)) + override_rv = session.get(pagure_override_url, timeout=30) + if override_rv.status_code == 200: + override_yaml = yaml.safe_load(override_rv.text) + return override_yaml.get('bugzilla_contact', {}) + return {} + def main(self): """The entrypoint to the script.""" global envname, env, projects_dict @@ -661,11 +663,22 @@ class DistgitBugzillaSync: print(f"Ignoring: {product}/{project['name']}") continue + owner = project["poc"] + # Check if the project is retired in PDC, and if so set assignee to orphan. + if _is_retired(product, project): + owner = 'orphan' + + # Check if the Bugzilla ticket assignee has been manually overridden + override_yaml = self._get_override_yaml(project, self.session) + if override_yaml.get(product) \ + and isinstance(override_yaml[product], str): + owner = override_yaml[product] + try: bugzilla.add_edit_component( package=project["name"], collection=product, - owner=project['poc'], + owner=owner, description=project['summary'], qacontact=None, cclist=project['watchers']