mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
gitlab push_commands will work
This commit is contained in:
@ -134,18 +134,24 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
|
|||||||
|
|
||||||
await handle_request(url, body, log_context, sender_id)
|
await handle_request(url, body, log_context, sender_id)
|
||||||
elif data.get('object_kind') == 'push' and data.get('event_name') == 'push':
|
elif data.get('object_kind') == 'push' and data.get('event_name') == 'push':
|
||||||
commands_on_push = get_settings().get(f"gitlab.push_commands", {})
|
|
||||||
handle_push_trigger = get_settings().get(f"gitlab.handle_push_trigger", False)
|
|
||||||
if not commands_on_push or not handle_push_trigger:
|
|
||||||
get_logger().info("Push event, but no push commands found or push trigger is disabled")
|
|
||||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
|
||||||
try:
|
try:
|
||||||
project_id = data['project_id']
|
project_id = data['project_id']
|
||||||
commit_sha = data['checkout_sha']
|
commit_sha = data['checkout_sha']
|
||||||
url = await get_mr_url_from_commit_sha(commit_sha, gitlab_token, project_id)
|
url = await get_mr_url_from_commit_sha(commit_sha, gitlab_token, project_id)
|
||||||
if not url:
|
if not url:
|
||||||
get_logger().info(f"No MR found for commit: {commit_sha}")
|
get_logger().info(f"No MR found for commit: {commit_sha}")
|
||||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
return JSONResponse(status_code=status.HTTP_200_OK,
|
||||||
|
content=jsonable_encoder({"message": "success"}))
|
||||||
|
|
||||||
|
# we need first to apply_repo_settings
|
||||||
|
apply_repo_settings(url)
|
||||||
|
commands_on_push = get_settings().get(f"gitlab.push_commands", {})
|
||||||
|
handle_push_trigger = get_settings().get(f"gitlab.handle_push_trigger", False)
|
||||||
|
if not commands_on_push or not handle_push_trigger:
|
||||||
|
get_logger().info("Push event, but no push commands found or push trigger is disabled")
|
||||||
|
return JSONResponse(status_code=status.HTTP_200_OK,
|
||||||
|
content=jsonable_encoder({"message": "success"}))
|
||||||
|
|
||||||
get_logger().debug(f'A push event has been received: {url}')
|
get_logger().debug(f'A push event has been received: {url}')
|
||||||
await _perform_commands_gitlab("push_commands", PRAgent(), url, log_context)
|
await _perform_commands_gitlab("push_commands", PRAgent(), url, log_context)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -180,7 +180,7 @@ pr_commands = [
|
|||||||
"/improve",
|
"/improve",
|
||||||
]
|
]
|
||||||
handle_push_trigger = false
|
handle_push_trigger = false
|
||||||
commands = [
|
push_commands = [
|
||||||
"/describe",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user