Update GitHub app

This commit is contained in:
Ori Kotek
2023-07-16 15:42:50 +03:00
parent 704030230f
commit 93311a9d9b
3 changed files with 22 additions and 27 deletions

View File

@ -56,7 +56,7 @@ async def handle_request(body):
api_url = pull_request.get("url", None)
if api_url is None:
return {}
await agent.handle_request(api_url, "please review")
await agent.handle_request(api_url, "/review")
else:
return {}

View File

@ -31,6 +31,7 @@ async def polling_loop():
last_modified = [None]
git_provider = get_git_provider()()
user_id = git_provider.get_user_id()
agent = PRAgent()
try:
deployment_type = settings.github.deployment_type
token = settings.github.user_token
@ -90,19 +91,8 @@ async def polling_loop():
continue
rest_of_comment = comment_body.split(user_tag)[1].strip()
if any(cmd in rest_of_comment for cmd in ["/review", "/review_pr"]):
await PRReviewer(pr_url).review()
elif any(cmd in rest_of_comment for cmd in ["/describe", "/describe_pr"]):
await PRDescription(pr_url).describe()
elif any(cmd in rest_of_comment for cmd in ["/improve", "/improve_code"]):
await PRCodeSuggestions(pr_url).suggest()
elif any(cmd in rest_of_comment for cmd in ["/ask", "/ask_question"]):
pattern = r'(/ask|/ask_question)\s*(.*)'
matches = re.findall(pattern, rest_of_comment, re.IGNORECASE)
if matches:
question = matches[0][1]
await PRQuestions(pr_url, question).answer()
else:
success = await agent.handle_request(pr_url, rest_of_comment)
if not success:
git_provider.set_pr(pr_url)
git_provider.publish_comment("### How to user PR-Agent\n" +
bot_help_text(user_id))