From bd611bc1c2c627466e6ea465121a90e28d863fa8 Mon Sep 17 00:00:00 2001 From: med8bra Date: Mon, 13 Jan 2025 22:22:13 +0100 Subject: [PATCH] fix(azure-provider): handle renamed files as new files This fixes a bug when azure-provider tries to fetch original content of a renamed file and fails since the file doesn't exist in base yet. Also handles case when `diff_type` includes multiple actions as `edit, rename`. This can be improved to fetch the actual old content using the old path before renaming, but IMO for azure devops since its dying anyway, this fix should be enough. --- pr_agent/git_providers/azuredevops_provider.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/git_providers/azuredevops_provider.py b/pr_agent/git_providers/azuredevops_provider.py index ee7eabec..eb362af3 100644 --- a/pr_agent/git_providers/azuredevops_provider.py +++ b/pr_agent/git_providers/azuredevops_provider.py @@ -326,13 +326,13 @@ class AzureDevopsProvider(GitProvider): edit_type = EDIT_TYPE.ADDED elif diff_types[file] == "delete": edit_type = EDIT_TYPE.DELETED - elif diff_types[file] == "rename": + elif "rename" in diff_types[file]: # diff_type can be `rename` | `edit, rename` edit_type = EDIT_TYPE.RENAMED version = GitVersionDescriptor( version=base_sha.commit_id, version_type="commit" ) - if edit_type == EDIT_TYPE.ADDED: + if edit_type == EDIT_TYPE.ADDED or edit_type == EDIT_TYPE.RENAMED: original_file_content_str = "" else: try: