clan-merge: fix crash on PRs with assignees = None
All checks were successful
build / test (push) Successful in 9s

This commit is contained in:
DavHau 2023-07-26 16:04:33 +02:00
parent 6168cb7229
commit 9127560a78

View File

@ -31,13 +31,14 @@ def is_ci_green(pr: dict) -> bool:
def decide_merge(pr: dict, allowed_users: list[str], bot_name: str) -> bool: def decide_merge(pr: dict, allowed_users: list[str], bot_name: str) -> bool:
assignees = pr["assignees"] if pr["assignees"] else []
if ( if (
pr["user"]["login"] in allowed_users pr["user"]["login"] in allowed_users
and pr["mergeable"] is True and pr["mergeable"] is True
and not pr["title"].startswith("WIP:") and not pr["title"].startswith("WIP:")
and pr["state"] == "open" and pr["state"] == "open"
# check if bot is assigned # 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) and is_ci_green(pr)
): ):
return True return True
@ -124,7 +125,6 @@ def clan_merge(
Do="merge", Do="merge",
) )
data_encoded = json.dumps(data).encode("utf8") data_encoded = json.dumps(data).encode("utf8")
print(data)
req = urllib.request.Request( req = urllib.request.Request(
url, data=data_encoded, headers={"Content-Type": "application/json"} url, data=data_encoded, headers={"Content-Type": "application/json"}
) )