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.
This commit is contained in:
med8bra
2025-01-13 22:22:13 +01:00
committed by GitHub
parent b3f116bb35
commit bd611bc1c2

View File

@ -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: