mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 04:40:38 +08:00
revert azuredevops_provider.py change
This commit is contained in:
@ -10,7 +10,6 @@ from .git_provider import GitProvider
|
|||||||
from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo
|
from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo
|
||||||
|
|
||||||
AZURE_DEVOPS_AVAILABLE = True
|
AZURE_DEVOPS_AVAILABLE = True
|
||||||
MAX_PR_DESCRIPTION_LENGTH = 4000-1
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
@ -325,12 +324,6 @@ class AzureDevopsProvider(GitProvider):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def publish_description(self, pr_title: str, pr_body: str):
|
def publish_description(self, pr_title: str, pr_body: str):
|
||||||
if len(pr_body) > MAX_PR_DESCRIPTION_LENGTH:
|
|
||||||
trunction_message = " ... (description truncated due to length limit)"
|
|
||||||
pr_body = pr_body[:MAX_PR_DESCRIPTION_LENGTH - len(trunction_message)] + trunction_message
|
|
||||||
get_logger().warning(
|
|
||||||
"PR description exceeds the maximum character limit of 4000. Truncating the description."
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
updated_pr = GitPullRequest()
|
updated_pr = GitPullRequest()
|
||||||
updated_pr.title = pr_title
|
updated_pr.title = pr_title
|
||||||
@ -460,23 +453,18 @@ class AzureDevopsProvider(GitProvider):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_pr_url(pr_url: str) -> Tuple[str, str, int]:
|
def _parse_pr_url(pr_url: str) -> Tuple[str, str, int]:
|
||||||
parsed_url = urlparse(pr_url)
|
parsed_url = urlparse(pr_url)
|
||||||
|
|
||||||
path_parts = parsed_url.path.strip("/").split("/")
|
path_parts = parsed_url.path.strip("/").split("/")
|
||||||
|
|
||||||
# support legacy urls
|
if len(path_parts) < 6 or path_parts[4] != "pullrequest":
|
||||||
# https://learn.microsoft.com/en-us/azure/devops/extend/develop/work-with-urls?view=azure-devops&tabs=http
|
|
||||||
path_offset = 0
|
|
||||||
if "visualstudio" in pr_url:
|
|
||||||
path_offset = 1
|
|
||||||
|
|
||||||
if len(path_parts) < (6 - path_offset) or path_parts[4 - path_offset] != "pullrequest":
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"The provided URL does not appear to be a Azure DevOps PR URL"
|
"The provided URL does not appear to be a Azure DevOps PR URL"
|
||||||
)
|
)
|
||||||
|
|
||||||
workspace_slug = path_parts[1 - path_offset]
|
workspace_slug = path_parts[1]
|
||||||
repo_slug = path_parts[3 - path_offset]
|
repo_slug = path_parts[3]
|
||||||
try:
|
try:
|
||||||
pr_number = int(path_parts[5 - path_offset])
|
pr_number = int(path_parts[5])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise ValueError("Unable to convert PR number to integer") from e
|
raise ValueError("Unable to convert PR number to integer") from e
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user