Skip to content

Commit

Permalink
Merge pull request #1274 from CoryBall/azure-devops-pr-new-file-error…
Browse files Browse the repository at this point in the history
…-fix

bug-fix_azuredevops-new-file
  • Loading branch information
mrT23 authored Oct 8, 2024
2 parents 4b05a3e + a476e85 commit bb84063
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pr_agent/git_providers/azuredevops_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,22 @@ def get_diff_files(self) -> list[FilePatchInfo]:
version = GitVersionDescriptor(
version=base_sha.commit_id, version_type="commit"
)
try:
original_file_content_str = self.azure_devops_client.get_item(
repository_id=self.repo_slug,
path=file,
project=self.workspace_slug,
version_descriptor=version,
download=False,
include_content=True,
)
original_file_content_str = original_file_content_str.content
except Exception as error:
get_logger().error(f"Failed to retrieve original file content of {file} at version {version}", error=error)
if edit_type == EDIT_TYPE.ADDED:
original_file_content_str = ""
else:
try:
original_file_content_str = self.azure_devops_client.get_item(
repository_id=self.repo_slug,
path=file,
project=self.workspace_slug,
version_descriptor=version,
download=False,
include_content=True,
)
original_file_content_str = original_file_content_str.content
except Exception as error:
get_logger().error(f"Failed to retrieve original file content of {file} at version {version}", error=error)
original_file_content_str = ""

patch = load_large_diff(
file, new_file_content_str, original_file_content_str, show_warning=False
Expand Down

0 comments on commit bb84063

Please sign in to comment.