mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
use sender_type on bot check
This commit is contained in:
@ -118,13 +118,13 @@ 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
|
# logic to ignore PRs opened by bot
|
||||||
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False):
|
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot":
|
||||||
if sender.endswith('[bot]'):
|
get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting")
|
||||||
get_logger().info(f"Ignoring PR by sender '{sender}' due to github_app.ignore_bot_pr setting")
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
title = body.get("pull_request", {}).get("title", "")
|
title = body.get("pull_request", {}).get("title", "")
|
||||||
@ -230,9 +230,11 @@ def handle_closed_pr(body, event, action, log_context):
|
|||||||
def get_log_context(body, event, action, build_number):
|
def get_log_context(body, event, action, build_number):
|
||||||
sender = ""
|
sender = ""
|
||||||
sender_id = ""
|
sender_id = ""
|
||||||
|
sender_type = ""
|
||||||
try:
|
try:
|
||||||
sender = body.get("sender", {}).get("login")
|
sender = body.get("sender", {}).get("login")
|
||||||
sender_id = body.get("sender", {}).get("id")
|
sender_id = body.get("sender", {}).get("id")
|
||||||
|
sender_type = body.get("sender", {}).get("type")
|
||||||
repo = body.get("repository", {}).get("full_name", "")
|
repo = body.get("repository", {}).get("full_name", "")
|
||||||
git_org = body.get("organization", {}).get("login", "")
|
git_org = body.get("organization", {}).get("login", "")
|
||||||
app_name = get_settings().get("CONFIG.APP_NAME", "Unknown")
|
app_name = get_settings().get("CONFIG.APP_NAME", "Unknown")
|
||||||
@ -242,7 +244,7 @@ def get_log_context(body, event, action, build_number):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().error("Failed to get log context", e)
|
get_logger().error("Failed to get log context", e)
|
||||||
log_context = {}
|
log_context = {}
|
||||||
return log_context, sender, sender_id
|
return log_context, sender, sender_id, sender_type
|
||||||
|
|
||||||
|
|
||||||
async def handle_request(body: Dict[str, Any], event: str):
|
async def handle_request(body: Dict[str, Any], event: str):
|
||||||
@ -257,7 +259,7 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
if not action:
|
if not action:
|
||||||
return {}
|
return {}
|
||||||
agent = PRAgent()
|
agent = PRAgent()
|
||||||
log_context, sender, sender_id = get_log_context(body, event, action, build_number)
|
log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number)
|
||||||
|
|
||||||
# handle comments on PRs
|
# handle comments on PRs
|
||||||
if action == 'created':
|
if action == 'created':
|
||||||
@ -266,7 +268,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, action, log_context, agent)
|
await handle_new_pr_opened(body, event, sender, sender_id, sender_type, 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)
|
||||||
|
Reference in New Issue
Block a user