From d06450b055ee7e1ec1d3a8c4b4050f6cf8db0823 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 3 Oct 2022 14:51:40 +0000 Subject: [PATCH] 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 --- scripts/set_assignees.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/set_assignees.py b/scripts/set_assignees.py index bc23451ca89..9649645fe3c 100755 --- a/scripts/set_assignees.py +++ b/scripts/set_assignees.py @@ -93,9 +93,12 @@ def process_pr(gh, maintainer_file, number): log(f"Submitted by: {pr.user.login}") log(f"candidate maintainers: {sm}") + maintainer = "None" + maintainers = list(sm.keys()) + prop = 0 - if sm: - maintainer = list(sm.keys())[0] + if maintainers: + maintainer = maintainers[0] if len(ac) > 1 and list(ac.values())[0] == list(ac.values())[1]: log("++ Platform/Drivers takes precedence over subsystem...") @@ -103,8 +106,10 @@ def process_pr(gh, maintainer_file, number): if 'Documentation' in aa: log("++ With multiple areas of same weight including docs, take something else other than Documentation as the maintainer") for a in all_areas: - if a.name == aa and a.maintainers[0] == maintainer: - maintainer = list(sm.keys())[1] + if (a.name == aa and + a.maintainers and a.maintainers[0] == maintainer and + len(maintainers) > 1): + maintainer = maintainers[1] elif 'Platform' in aa: log(f"Set maintainer of area {aa}") for a in all_areas: @@ -129,8 +134,7 @@ def process_pr(gh, maintainer_file, number): prop = (maint[maintainer] / num_files) * 100 if prop < 20: maintainer = "None" - else: - maintainer = "None" + log(f"Picked maintainer: {maintainer} ({prop:.2f}% ownership)") log("+++++++++++++++++++++++++")