From 19f11f99ce9bc801a804c4d2dff655fdd3258be8 Mon Sep 17 00:00:00 2001 From: Ori Kotek Date: Sun, 16 Jul 2023 13:36:02 +0300 Subject: [PATCH] Github action support for new style commands --- pr_agent/servers/github_action_runner.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 953b0b8f..49e58220 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -1,8 +1,11 @@ import asyncio import json import os +import re from pr_agent.config_loader import settings +from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions +from pr_agent.tools.pr_description import PRDescription from pr_agent.tools.pr_questions import PRQuestions from pr_agent.tools.pr_reviewer import PRReviewer @@ -48,10 +51,19 @@ async def run_action(): if comment_body: pr_url = event_payload.get("issue", {}).get("pull_request", {}).get("url", None) if pr_url: - if comment_body.strip().lower() == "review": + body = comment_body.strip().lower() + if any(cmd in body for cmd in ["/review", "/review_pr"]): await PRReviewer(pr_url).review() - elif comment_body.lstrip().lower().startswith("answer"): - await PRQuestions(pr_url, comment_body).answer() + elif any(cmd in body for cmd in ["/describe", "/describe_pr"]): + await PRDescription(pr_url).describe() + elif any(cmd in body for cmd in ["/improve", "/improve_code"]): + await PRCodeSuggestions(pr_url).suggest() + elif any(cmd in body for cmd in ["/ask", "/ask_question"]): + pattern = r'(/ask|/ask_question)\s*(.*)' + matches = re.findall(pattern, comment_body, re.IGNORECASE) + if matches: + question = matches[0][1] + await PRQuestions(pr_url, question).answer() if __name__ == '__main__':