From 74ac8c140c28b1fa5c98a490f4c4716368e8eff7 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 21 Jul 2023 09:36:19 -0400 Subject: [PATCH] gitea: Support missing head/base refs. --- zerver/webhooks/gitea/view.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zerver/webhooks/gitea/view.py b/zerver/webhooks/gitea/view.py index dae6ceae47..09b2235811 100644 --- a/zerver/webhooks/gitea/view.py +++ b/zerver/webhooks/gitea/view.py @@ -31,8 +31,10 @@ def format_pull_request_event(payload: WildValue, include_title: bool = False) - target_branch = None base_branch = None if action != "edited": - target_branch = payload["pull_request"]["head"]["ref"].tame(check_string) - base_branch = payload["pull_request"]["base"]["ref"].tame(check_string) + if "head" in payload["pull_request"]: + target_branch = payload["pull_request"]["head"]["ref"].tame(check_string) + if "base" in payload["pull_request"]: + base_branch = payload["pull_request"]["base"]["ref"].tame(check_string) title = payload["pull_request"]["title"].tame(check_string) if include_title else None stringified_assignee = assignee["login"].tame(check_string) if assignee else None