Allow overriding GitHub app default action by using repo local file

This commit is contained in:
Ori Kotek
2023-08-30 12:12:09 +03:00
parent f14c5d296a
commit d64b1f80da

View File

@ -12,6 +12,7 @@ from starlette_context import context
from starlette_context.middleware import RawContextMiddleware
from pr_agent.agent.pr_agent import PRAgent
from pr_agent.algo.utils import update_settings_from_args
from pr_agent.config_loader import get_settings, global_settings
from pr_agent.git_providers import get_git_provider
from pr_agent.servers.utils import verify_signature
@ -123,8 +124,13 @@ async def handle_request(body: Dict[str, Any], event: str):
return {}
logging.info(f"Performing review because of event={event} and action={action}")
for command in get_settings().github_app.pr_commands:
logging.info(f"Performing command: {command}")
await agent.handle_request(api_url, command)
split_command = command.split(" ")
command = split_command[0]
args = split_command[1:]
other_args = update_settings_from_args(args)
new_command = ' '.join([command] + other_args)
logging.info(f"Performing command: {new_command}")
await agent.handle_request(api_url, new_command)
logging.info("event or action does not require handling")
return {}