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