mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 03:40:38 +08:00
feat: gitlab skip source, target and labels
This commit is contained in:
@ -124,11 +124,26 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
|
||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
||||
|
||||
log_context["sender"] = sender
|
||||
excluded_source_branches = get_settings().get("gitlab.excluded_source_branches", [])
|
||||
excluded_target_branches = get_settings().get("gitlab.excluded_target_branches", [])
|
||||
excluded_labels = get_settings().get("gitlab.excluded_labels", [])
|
||||
if data.get('object_kind') == 'merge_request' and data['object_attributes'].get('action') in ['open', 'reopen']:
|
||||
url = data['object_attributes'].get('url')
|
||||
draft = data['object_attributes'].get('draft')
|
||||
source_branch = data['object_attributes'].get('source_branch')
|
||||
target_branch = data['object_attributes'].get('target_branch')
|
||||
labels = data['object_attributes'].get('labels').map(lambda x: x['title'])
|
||||
|
||||
get_logger().info(f"New merge request: {url}")
|
||||
|
||||
if target_branch in excluded_target_branches or source_branch in excluded_source_branches:
|
||||
get_logger().info(f"Skipping excluded branch MR: {url}")
|
||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
||||
|
||||
if labels.intersection(excluded_labels):
|
||||
get_logger().info(f"Skipping excluded label MR: {url}")
|
||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
||||
|
||||
if draft:
|
||||
get_logger().info(f"Skipping draft MR: {url}")
|
||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
||||
@ -138,7 +153,7 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
|
||||
if 'merge_request' in data:
|
||||
mr = data['merge_request']
|
||||
url = mr.get('url')
|
||||
|
||||
|
||||
get_logger().info(f"A comment has been added to a merge request: {url}")
|
||||
body = data.get('object_attributes', {}).get('note')
|
||||
if data.get('object_attributes', {}).get('type') == 'DiffNote' and '/ask' in body: # /ask_line
|
||||
|
@ -230,6 +230,9 @@ push_commands = [
|
||||
"/describe",
|
||||
"/review --pr_reviewer.num_code_suggestions=0",
|
||||
]
|
||||
excluded_target_branches = []
|
||||
excluded_source_branches = []
|
||||
excluded_labels = []
|
||||
|
||||
[bitbucket_app]
|
||||
pr_commands = [
|
||||
|
Reference in New Issue
Block a user