mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
Bitbucket Server: Add push_commands support when PR is updated (#2090)
Some checks are pending
Build-and-test / build-and-test (push) Waiting to run
Some checks are pending
Build-and-test / build-and-test (push) Waiting to run
This commit is contained in:
parent
a2b5ae87d7
commit
bfc82390dd
1 changed files with 16 additions and 3 deletions
|
|
@ -154,7 +154,8 @@ async def handle_webhook(background_tasks: BackgroundTasks, request: Request):
|
||||||
|
|
||||||
commands_to_run = []
|
commands_to_run = []
|
||||||
|
|
||||||
if data["eventKey"] == "pr:opened":
|
if (data["eventKey"] == "pr:opened"
|
||||||
|
or (data["eventKey"] == "repo:refs_changed" and data.get("pullRequest", {}).get("id", -1) != -1)): # push event; -1 for push unassigned to a PR: #Check auto commands for creation/updating
|
||||||
apply_repo_settings(pr_url)
|
apply_repo_settings(pr_url)
|
||||||
if not should_process_pr_logic(data):
|
if not should_process_pr_logic(data):
|
||||||
get_logger().info(f"PR ignored due to config settings", **log_context)
|
get_logger().info(f"PR ignored due to config settings", **log_context)
|
||||||
|
|
@ -163,9 +164,21 @@ async def handle_webhook(background_tasks: BackgroundTasks, request: Request):
|
||||||
)
|
)
|
||||||
if get_settings().config.disable_auto_feedback: # auto commands for PR, and auto feedback is disabled
|
if get_settings().config.disable_auto_feedback: # auto commands for PR, and auto feedback is disabled
|
||||||
get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {pr_url}", **log_context)
|
get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {pr_url}", **log_context)
|
||||||
return
|
return JSONResponse(
|
||||||
|
status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "PR ignored due to auto feedback not enabled"})
|
||||||
|
)
|
||||||
get_settings().set("config.is_auto_command", True)
|
get_settings().set("config.is_auto_command", True)
|
||||||
|
if data["eventKey"] == "pr:opened":
|
||||||
commands_to_run.extend(_get_commands_list_from_settings('BITBUCKET_SERVER.PR_COMMANDS'))
|
commands_to_run.extend(_get_commands_list_from_settings('BITBUCKET_SERVER.PR_COMMANDS'))
|
||||||
|
else: #Has to be: data["eventKey"] == "pr:from_ref_updated"
|
||||||
|
if not get_settings().get("BITBUCKET_SERVER.HANDLE_PUSH_TRIGGER"):
|
||||||
|
get_logger().info(f"Push trigger is disabled, skipping push commands for PR {pr_url}", **log_context)
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "PR ignored due to push trigger not enabled"})
|
||||||
|
)
|
||||||
|
|
||||||
|
get_settings().set("config.is_new_pr", False)
|
||||||
|
commands_to_run.extend(_get_commands_list_from_settings('BITBUCKET_SERVER.PUSH_COMMANDS'))
|
||||||
elif data["eventKey"] == "pr:comment:added":
|
elif data["eventKey"] == "pr:comment:added":
|
||||||
commands_to_run.append(data["comment"]["text"])
|
commands_to_run.append(data["comment"]["text"])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue