Update the open bugs when the corresponding package changes maintainer

Fixes https://pagure.io/fedora-infrastructure/issue/6940

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2019-11-22 17:08:54 +01:00
parent 0e036348d0
commit b1bb0c02a4
2 changed files with 58 additions and 0 deletions

View file

@ -13,6 +13,12 @@ notify_emails = [
"Fedora Modules" = "Fedora Modules"
"Fedora EPEL" = "Fedora EPEL"
[products_versions]
"Fedora" = ["rawhide", "31", "30", "29"]
"Fedora Container" = ["rawhide", "29"]
"Fedora Modules" = []
"Fedora EPEL" = ["epel8", "epel7", "el6"]
[namespace_to_product]
"rpms" = "Fedora" # except EPEL...
"container" = "Fedora Container"
@ -23,6 +29,10 @@ notify_emails = [
"modules" = "module"
"container" = "container"
bz_maintainer_change_comment = """
This package has changed maintainer in the Fedora.
Reassigning to the new maintainer of this component.
"""
## EMAIL TEMPLATES

View file

@ -234,6 +234,45 @@ 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):
'''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.
'''
bz_query = {}
bz_query['product'] = product
bz_query['component'] = name
bz_query['bug_status'] = [
'NEW', 'ASSIGNED', 'ON_DEV', 'ON_QA', 'MODIFIED', 'POST',
'FAILS_QA', 'PASSES_QA', 'RELEASE_PENDING']
# Update only maintained releases
bz_query['version'] = self.config["products_versions"][product]
query_results = self.server.query(bz_query)
for bug in query_results:
if bug.assigned_to == prev_poc and bug.assigned_to != new_poc:
if self.config["verbose"]:
print(
f' - reassigning bug #{bug.bug_id} '
f'from {bug.assigned_to} to {new_poc}'
)
if not self.config["dryrun"]:
try:
bug.setassignee(
assigned_to=new_poc,
comment=self.config['bz_maintainer_change_comment'],
)
except xmlrpc.client.Fault as e:
# Output something useful in args
e.args = (data, e.faultCode, e.faultString)
raise
except xmlrpc.client.ProtocolError as e:
e.args = ('ProtocolError', e.errcode, e.errmsg)
raise
def add_edit_component(self, package, collection, owner, description=None,
qacontact=None, cclist=None, print_fas_names=False):
'''Add or update a component to have the values specified.
@ -344,6 +383,8 @@ class BugzillaProxy:
else:
print(f" {key} changed from `{old_value}` to `{new_value}`")
owner_changed = "initialowner" in data
# FIXME: initialowner has been made mandatory for some
# reason. Asking dkl why.
data['initialowner'] = owner_email
@ -357,6 +398,13 @@ class BugzillaProxy:
except xmlrpc.client.ProtocolError as e:
e.args = ('ProtocolError', e.errcode, e.errmsg)
raise
if owner_changed:
self.update_open_bugs(
new_poc=owner_email,
prev_poc=product[pkg_key]['initialowner'],
name=package,
product=self.config['products'][collection],
)
else:
if self.config.get("print-no-change"):
print(f"[NOCHANGE] {package}/{self.config['products'][collection]}")