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:
parent
0e036348d0
commit
b1bb0c02a4
2 changed files with 58 additions and 0 deletions
|
@ -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]}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue