scripts: set_assignees: handle the documentation + unmaintained case

The script right now assumes that all the areas have a maintainer and
that the second area in particular has one in case of Documentation,
that results in a ValueError when it's not the case. Handle that by
checking the lists before using them.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2022-10-03 14:51:40 +00:00 committed by Fabio Baltieri
commit d06450b055

View file

@ -93,9 +93,12 @@ def process_pr(gh, maintainer_file, number):
log(f"Submitted by: {pr.user.login}") log(f"Submitted by: {pr.user.login}")
log(f"candidate maintainers: {sm}") log(f"candidate maintainers: {sm}")
maintainer = "None"
maintainers = list(sm.keys())
prop = 0 prop = 0
if sm: if maintainers:
maintainer = list(sm.keys())[0] maintainer = maintainers[0]
if len(ac) > 1 and list(ac.values())[0] == list(ac.values())[1]: if len(ac) > 1 and list(ac.values())[0] == list(ac.values())[1]:
log("++ Platform/Drivers takes precedence over subsystem...") log("++ Platform/Drivers takes precedence over subsystem...")
@ -103,8 +106,10 @@ def process_pr(gh, maintainer_file, number):
if 'Documentation' in aa: if 'Documentation' in aa:
log("++ With multiple areas of same weight including docs, take something else other than Documentation as the maintainer") log("++ With multiple areas of same weight including docs, take something else other than Documentation as the maintainer")
for a in all_areas: for a in all_areas:
if a.name == aa and a.maintainers[0] == maintainer: if (a.name == aa and
maintainer = list(sm.keys())[1] a.maintainers and a.maintainers[0] == maintainer and
len(maintainers) > 1):
maintainer = maintainers[1]
elif 'Platform' in aa: elif 'Platform' in aa:
log(f"Set maintainer of area {aa}") log(f"Set maintainer of area {aa}")
for a in all_areas: for a in all_areas:
@ -129,8 +134,7 @@ def process_pr(gh, maintainer_file, number):
prop = (maint[maintainer] / num_files) * 100 prop = (maint[maintainer] / num_files) * 100
if prop < 20: if prop < 20:
maintainer = "None" maintainer = "None"
else:
maintainer = "None"
log(f"Picked maintainer: {maintainer} ({prop:.2f}% ownership)") log(f"Picked maintainer: {maintainer} ({prop:.2f}% ownership)")
log("+++++++++++++++++++++++++") log("+++++++++++++++++++++++++")