mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-10 15:50:37 +08:00
feat: enhance Azure DevOps integration by adding work item as a ticket retrieval methods - Supporting ticket context for Azure DevOps
Signed-off-by: abishlal <abishlalns03@gmail.com>
This commit is contained in:
@ -3,6 +3,7 @@ import traceback
|
||||
|
||||
from pr_agent.config_loader import get_settings
|
||||
from pr_agent.git_providers import GithubProvider
|
||||
from pr_agent.git_providers import AzureDevopsProvider
|
||||
from pr_agent.log import get_logger
|
||||
|
||||
# Compile the regex pattern once, outside the function
|
||||
@ -131,6 +132,32 @@ async def extract_tickets(git_provider):
|
||||
|
||||
return tickets_content
|
||||
|
||||
elif isinstance(git_provider, AzureDevopsProvider):
|
||||
tickets_info = git_provider.get_linked_work_items()
|
||||
tickets_content = []
|
||||
for ticket in tickets_info:
|
||||
try:
|
||||
ticket_body_str = ticket.get("body", "")
|
||||
if len(ticket_body_str) > MAX_TICKET_CHARACTERS:
|
||||
ticket_body_str = ticket_body_str[:MAX_TICKET_CHARACTERS] + "..."
|
||||
|
||||
tickets_content.append(
|
||||
{
|
||||
"ticket_id": ticket.get("id"),
|
||||
"ticket_url": ticket.get("url"),
|
||||
"title": ticket.get("title"),
|
||||
"body": ticket_body_str,
|
||||
"labels": ", ".join(ticket.get("labels", [])),
|
||||
"requirements": ticket.get("acceptance_criteria", ""),
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
get_logger().error(
|
||||
f"Error processing Azure DevOps ticket: {e}",
|
||||
artifact={"traceback": traceback.format_exc()},
|
||||
)
|
||||
return tickets_content
|
||||
|
||||
except Exception as e:
|
||||
get_logger().error(f"Error extracting tickets error= {e}",
|
||||
artifact={"traceback": traceback.format_exc()})
|
||||
|
Reference in New Issue
Block a user