use more descriptive variable names in add_edit_component()

Also, don't use `owner`, 'qacontact' for two purposes: first for the FAS
username, then for the email address of the same person.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2019-11-21 15:25:08 +01:00
parent fd66fa51c5
commit 06b0f23201

View file

@ -217,24 +217,23 @@ class BugzillaProxy:
'''Add or update a component to have the values specified. '''Add or update a component to have the values specified.
''' '''
# Turn the cclist into something usable by bugzilla # Turn the cclist into something usable by bugzilla
initialCCList = [] initialCCEmails = []
initialCCList_username = [] initialCCFASNames = []
for watcher in cclist: for watcher in cclist:
bz_email = self._get_bugzilla_email(watcher) bz_email = self._get_bugzilla_email(watcher)
if bz_email: if bz_email:
initialCCList.append(bz_email) initialCCEmails.append(bz_email)
initialCCList_username.append(watcher) initialCCFASNames.append(watcher)
else: else:
print(f"** {watcher} has no bugzilla_email or mailing_list set " print(f"** {watcher} has no bugzilla_email or mailing_list set "
f"({collection}/{package}) **") f"({collection}/{package}) **")
# Add owner to the cclist so comaintainers taking over a bug don't # Add owner to the cclist so comaintainers taking over a bug don't
# have to do this manually # have to do this manually
owner_name = owner owner_email = self._get_bugzilla_email(owner)
owner = self._get_bugzilla_email(owner) if owner_email not in initialCCEmails:
if owner not in initialCCList: initialCCEmails.append(owner_email)
initialCCList.append(owner) initialCCFASNames.append(owner)
initialCCList_username.append(owner_name)
# Lookup product # Lookup product
try: try:
@ -254,26 +253,26 @@ class BugzillaProxy:
# Grab bugzilla email for things changable via xmlrpc # Grab bugzilla email for things changable via xmlrpc
if qacontact: if qacontact:
qacontact = self._get_bugzilla_email(qacontact) qacontact_email = self._get_bugzilla_email(qacontact)
else: else:
qacontact = 'extras-qa@fedoraproject.org' qacontact_email = 'extras-qa@fedoraproject.org'
# Check for changes to the owner, qacontact, or description # Check for changes to the owner, qacontact, or description
if product[pkgKey]['initialowner'] != owner: if product[pkgKey]['initialowner'] != owner_email:
data['initialowner'] = owner data['initialowner'] = owner_email
if description and product[pkgKey]['description'] != description: if description and product[pkgKey]['description'] != description:
data['description'] = description data['description'] = description
if qacontact and product[pkgKey]['initialqacontact'] != qacontact: if qacontact and product[pkg_key]['initialqacontact'] != qacontact_email:
data['initialqacontact'] = qacontact data['initialqacontact'] = qacontact_email
if len(product[pkgKey]['initialcclist']) != len(initialCCList): if len(product[pkgKey]['initialcclist']) != len(initialCCEmails):
data['initialcclist'] = initialCCList data['initialcclist'] = initialCCEmails
else: else:
for ccMember in product[pkgKey]['initialcclist']: for cc_member in product[pkgKey]['initialcclist']:
if ccMember not in initialCCList: if cc_member not in initialCCEmails:
data['initialcclist'] = initialCCList data['initialcclist'] = initialCCEmails
break break
if data: if data:
@ -285,15 +284,19 @@ class BugzillaProxy:
print(f'[EDITCOMP] {data["product"]}/{data["component"]}') print(f'[EDITCOMP] {data["product"]}/{data["component"]}')
for key in ["initialowner", "description", "initialqacontact", "initialcclist"]: for key in ["initialowner", "description", "initialqacontact", "initialcclist"]:
if data.get(key): if data.get(key):
if output_user and key == "initialcclist": if output_user and key in ('initialowner', 'initialcclist'):
print(f" {key} changed from to `{initialCCList_username}`") if key == 'initialowner':
value = owner
else:
value = initialCCFASNames
print(f" {key} changed to `{value}`")
else: else:
print(f" {key} changed from `{product[pkgKey][key]} " print(f" {key} changed from `{product[pkgKey][key]} "
f"to `{data.get(key)}`") f"to `{data.get(key)}`")
# FIXME: initialowner has been made mandatory for some # FIXME: initialowner has been made mandatory for some
# reason. Asking dkl why. # reason. Asking dkl why.
data['initialowner'] = owner data['initialowner'] = owner_email
if not self.config["dryrun"]: if not self.config["dryrun"]:
try: try:
self.server.editcomponent(data) self.server.editcomponent(data)
@ -307,19 +310,19 @@ class BugzillaProxy:
else: else:
# Add component # Add component
if qacontact: if qacontact:
qacontact = self._get_bugzilla_email(qacontact) qacontact_email = self._get_bugzilla_email(qacontact)
else: else:
qacontact = 'extras-qa@fedoraproject.org' qacontact_email = 'extras-qa@fedoraproject.org'
data = { data = {
'product': self.config['products'][collection], 'product': self.config['products'][collection],
'component': package, 'component': package,
'description': description or 'NA', 'description': description or 'NA',
'initialowner': owner, 'initialowner': owner_email,
'initialqacontact': qacontact 'initialqacontact': qacontact_email
} }
if initialCCList: if initialCCEmails:
data['initialcclist'] = initialCCList data['initialcclist'] = initialCCEmails
if self.config["verbose"]: if self.config["verbose"]:
print('[ADDCOMP] %s/%s' % (data["product"], data["component"])) print('[ADDCOMP] %s/%s' % (data["product"], data["component"]))