mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 13:20:39 +08:00
added github action support
This commit is contained in:
@ -8,6 +8,7 @@ from pr_agent.config_loader import get_settings
|
|||||||
from pr_agent.git_providers import get_git_provider
|
from pr_agent.git_providers import get_git_provider
|
||||||
from pr_agent.git_providers.utils import apply_repo_settings
|
from pr_agent.git_providers.utils import apply_repo_settings
|
||||||
from pr_agent.log import get_logger
|
from pr_agent.log import get_logger
|
||||||
|
from pr_agent.servers.github_app import handle_line_comments
|
||||||
from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions
|
from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions
|
||||||
from pr_agent.tools.pr_description import PRDescription
|
from pr_agent.tools.pr_description import PRDescription
|
||||||
from pr_agent.tools.pr_reviewer import PRReviewer
|
from pr_agent.tools.pr_reviewer import PRReviewer
|
||||||
@ -114,6 +115,13 @@ async def run_action():
|
|||||||
is_pr = True
|
is_pr = True
|
||||||
else:
|
else:
|
||||||
url = event_payload.get("issue", {}).get("url")
|
url = event_payload.get("issue", {}).get("url")
|
||||||
|
try:
|
||||||
|
if 'subject_type' in event_payload["comment"] and event_payload["comment"]["subject_type"] == "line":
|
||||||
|
comment_body = handle_line_comments(event_payload, comment_body)
|
||||||
|
except Exception as e:
|
||||||
|
get_logger().error(f"Failed to handle line comments: {e}")
|
||||||
|
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
body = comment_body.strip().lower()
|
body = comment_body.strip().lower()
|
||||||
comment_id = event_payload.get("comment", {}).get("id")
|
comment_id = event_payload.get("comment", {}).get("id")
|
||||||
|
@ -100,8 +100,11 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
api_url = body["issue"]["pull_request"]["url"]
|
api_url = body["issue"]["pull_request"]["url"]
|
||||||
elif "comment" in body and "pull_request_url" in body["comment"]:
|
elif "comment" in body and "pull_request_url" in body["comment"]:
|
||||||
api_url = body["comment"]["pull_request_url"]
|
api_url = body["comment"]["pull_request_url"]
|
||||||
|
try:
|
||||||
if 'subject_type' in body["comment"] and body["comment"]["subject_type"] == "line":
|
if 'subject_type' in body["comment"] and body["comment"]["subject_type"] == "line":
|
||||||
comment_body = await handle_line_comments(action, body, comment_body, event)
|
comment_body = handle_line_comments(body, comment_body)
|
||||||
|
except Exception as e:
|
||||||
|
get_logger().error(f"Failed to handle line comments: {e}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
@ -193,7 +196,7 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
async def handle_line_comments(action, body, comment_body, event):
|
def handle_line_comments(body, comment_body):
|
||||||
# handle line comments
|
# handle line comments
|
||||||
start_line = body["comment"]["start_line"]
|
start_line = body["comment"]["start_line"]
|
||||||
end_line = body["comment"]["line"]
|
end_line = body["comment"]["line"]
|
||||||
@ -205,7 +208,6 @@ async def handle_line_comments(action, body, comment_body, event):
|
|||||||
side = body["comment"]["side"]
|
side = body["comment"]["side"]
|
||||||
comment_id = body["comment"]["id"]
|
comment_id = body["comment"]["id"]
|
||||||
if '/ask' in comment_body:
|
if '/ask' in comment_body:
|
||||||
get_logger().info(f"Handling line comment because of event={event} and action={action}")
|
|
||||||
comment_body = f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={comment_id} {question}"
|
comment_body = f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={comment_id} {question}"
|
||||||
return comment_body
|
return comment_body
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user