From c6a0567161f47abc6f0e00552ed2f11deec92275 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Fri, 12 Jun 2026 10:11:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(toolchain):=20=E6=B3=A8=E5=86=8C=20pull=5Fr?= =?UTF-8?q?equest=5Fsync=20=E5=92=8C=20pull=5Frequest=5Fcomment=20event=20?= =?UTF-8?q?type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea 对 PR branch push 发的是独立事件类型 pull_request_sync, 不是 pull_request + action=synchronize。 同时补注册 pull_request_comment(review comment)。 删除 _handle_pull_request 中永远不会触发的 synchronize 分支。 --- src/api/toolchain_routes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/toolchain_routes.py b/src/api/toolchain_routes.py index c6a09dd..12e4314 100644 --- a/src/api/toolchain_routes.py +++ b/src/api/toolchain_routes.py @@ -259,12 +259,10 @@ def _repo_fullname(payload: Dict[str, Any]) -> str: async def _handle_pull_request(payload: Dict[str, Any]) -> None: - """处理 pull_request 事件:opened → 通知 reviewer;synchronize → 通知 reviewer 重新 review。""" + """处理 pull_request 事件:opened → 通知 reviewer;closed → merge 通知。""" action = payload.get("action", "") if action == "opened": await _handle_pr_opened(payload) - elif action == "synchronize": - await _handle_pr_synchronize(payload) elif action == "closed": await _handle_pr_closed(payload) @@ -595,10 +593,12 @@ async def _handle_issue_comment(payload: Dict[str, Any]) -> None: _EVENT_HANDLERS: Dict[str, Any] = { "pull_request": _handle_pull_request, + "pull_request_sync": _handle_pr_synchronize, # Gitea: PR branch push 是独立事件类型 "pull_request_review": _handle_pull_request_review, "pull_request_review_approved": _handle_pull_request_review, "pull_request_review_rejected": _handle_pull_request_review, "pull_request_review_comment": _handle_pull_request_review, + "pull_request_comment": _handle_pull_request_review, # Gitea: review comment 独立事件类型 # Gitea v1.23.4 实际发出的 review 子事件(无 _review_ 中间段) "pull_request_approved": _handle_pull_request_review, "pull_request_rejected": _handle_pull_request_review, @@ -653,9 +653,11 @@ async def gitea_webhook( return Response(status_code=200, content="duplicate") # 4. 查找 handler + action = payload.get("action", "") + logger.info("[WEBHOOK] event=%s action=%s delivery=%s", x_gitea_event, action, x_gitea_delivery) handler = _EVENT_HANDLERS.get(x_gitea_event or "") if not handler: - logger.debug("Unhandled event type: %s", x_gitea_event) + logger.info("[WEBHOOK] Unhandled event type: %s", x_gitea_event) return Response(status_code=200, content=f"unhandled event: {x_gitea_event}")