From 9127560a78fa8c5d505ec18552350e871ece7a59 Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 26 Jul 2023 16:04:33 +0200 Subject: [PATCH] clan-merge: fix crash on PRs with assignees = None --- pkgs/clan-merge/clan_merge/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-merge/clan_merge/__init__.py b/pkgs/clan-merge/clan_merge/__init__.py index 65984b2..9216132 100644 --- a/pkgs/clan-merge/clan_merge/__init__.py +++ b/pkgs/clan-merge/clan_merge/__init__.py @@ -31,13 +31,14 @@ def is_ci_green(pr: dict) -> bool: def decide_merge(pr: dict, allowed_users: list[str], bot_name: str) -> bool: + assignees = pr["assignees"] if pr["assignees"] else [] if ( pr["user"]["login"] in allowed_users and pr["mergeable"] is True and not pr["title"].startswith("WIP:") and pr["state"] == "open" # check if bot is assigned - and any(reviewer["login"] == bot_name for reviewer in pr["assignees"]) + and any(assignee["login"] == bot_name for assignee in assignees) and is_ci_green(pr) ): return True @@ -124,7 +125,6 @@ def clan_merge( Do="merge", ) data_encoded = json.dumps(data).encode("utf8") - print(data) req = urllib.request.Request( url, data=data_encoded, headers={"Content-Type": "application/json"} )