Skip to content

Commit d06450b

Browse files
committed
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 <[email protected]>
1 parent 8b6ede6 commit d06450b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/set_assignees.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,23 @@ def process_pr(gh, maintainer_file, number):
9393
log(f"Submitted by: {pr.user.login}")
9494
log(f"candidate maintainers: {sm}")
9595

96+
maintainer = "None"
97+
maintainers = list(sm.keys())
98+
9699
prop = 0
97-
if sm:
98-
maintainer = list(sm.keys())[0]
100+
if maintainers:
101+
maintainer = maintainers[0]
99102

100103
if len(ac) > 1 and list(ac.values())[0] == list(ac.values())[1]:
101104
log("++ Platform/Drivers takes precedence over subsystem...")
102105
for aa in ac:
103106
if 'Documentation' in aa:
104107
log("++ With multiple areas of same weight including docs, take something else other than Documentation as the maintainer")
105108
for a in all_areas:
106-
if a.name == aa and a.maintainers[0] == maintainer:
107-
maintainer = list(sm.keys())[1]
109+
if (a.name == aa and
110+
a.maintainers and a.maintainers[0] == maintainer and
111+
len(maintainers) > 1):
112+
maintainer = maintainers[1]
108113
elif 'Platform' in aa:
109114
log(f"Set maintainer of area {aa}")
110115
for a in all_areas:
@@ -129,8 +134,7 @@ def process_pr(gh, maintainer_file, number):
129134
prop = (maint[maintainer] / num_files) * 100
130135
if prop < 20:
131136
maintainer = "None"
132-
else:
133-
maintainer = "None"
137+
134138
log(f"Picked maintainer: {maintainer} ({prop:.2f}% ownership)")
135139
log("+++++++++++++++++++++++++")
136140

0 commit comments

Comments
 (0)