always ignore bot

This commit is contained in:
mrT23
2024-03-25 09:04:07 +02:00
parent 695f0706a8
commit 3cdadb3ad1

View File

@ -118,15 +118,9 @@ async def handle_new_pr_opened(body: Dict[str, Any],
event: str, event: str,
sender: str, sender: str,
sender_id: str, sender_id: str,
sender_type: str,
action: str, action: str,
log_context: Dict[str, Any], log_context: Dict[str, Any],
agent: PRAgent): agent: PRAgent):
# logic to ignore PRs opened by bot
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot":
get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting")
return {}
title = body.get("pull_request", {}).get("title", "") title = body.get("pull_request", {}).get("title", "")
# logic to ignore PRs with specific titles (e.g. "[Auto] ...") # logic to ignore PRs with specific titles (e.g. "[Auto] ...")
@ -261,6 +255,11 @@ async def handle_request(body: Dict[str, Any], event: str):
agent = PRAgent() agent = PRAgent()
log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number) log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number)
# logic to ignore PRs opened by bot
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot":
get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting")
return {}
# handle comments on PRs # handle comments on PRs
if action == 'created': if action == 'created':
get_logger().debug(f'Request body', artifact=body, event=event) get_logger().debug(f'Request body', artifact=body, event=event)
@ -268,7 +267,7 @@ async def handle_request(body: Dict[str, Any], event: str):
# handle new PRs # handle new PRs
elif event == 'pull_request' and action != 'synchronize' and action != 'closed': elif event == 'pull_request' and action != 'synchronize' and action != 'closed':
get_logger().debug(f'Request body', artifact=body, event=event) get_logger().debug(f'Request body', artifact=body, event=event)
await handle_new_pr_opened(body, event, sender, sender_id, sender_type, action, log_context, agent) await handle_new_pr_opened(body, event, sender, sender_id, action, log_context, agent)
# handle pull_request event with synchronize action - "push trigger" for new commits # handle pull_request event with synchronize action - "push trigger" for new commits
elif event == 'pull_request' and action == 'synchronize': elif event == 'pull_request' and action == 'synchronize':
get_logger().debug(f'Request body', artifact=body, event=event) get_logger().debug(f'Request body', artifact=body, event=event)