From edc9d8944eac25e0a3074011117299fae5bd8ba6 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 26 Feb 2024 20:56:43 +0200 Subject: [PATCH] Refactor handle_closed_pr function to check for merged PRs --- pr_agent/servers/github_app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pr_agent/servers/github_app.py b/pr_agent/servers/github_app.py index f67e4818..34504dde 100644 --- a/pr_agent/servers/github_app.py +++ b/pr_agent/servers/github_app.py @@ -207,8 +207,11 @@ async def handle_push_trigger_for_new_commits(body: Dict[str, Any], def handle_closed_pr(body, event, action, log_context): - pull_request = body.get("pull_request") - api_url = pull_request.get("url") + pull_request = body.get("pull_request", {}) + is_merged = pull_request.get("merged", False) + if not is_merged: + return + api_url = pull_request.get("url", "") pr_statistics = get_git_provider()(pr_url=api_url).calc_pr_statistics(pull_request) with get_logger().contextualize(pr_statistics=pr_statistics): get_logger().info("PR-Agent statistics for closed PR", analytics=True)