Azure Devops: Set file content as empty string when error

This commit is contained in:
Brian Pham
2023-10-01 16:22:37 +00:00
parent 8d075b76ae
commit 4479c5f11b

View File

@ -100,14 +100,17 @@ class AzureDevopsProvider:
continue continue
version = GitVersionDescriptor(version=head_sha.commit_id, version_type='commit') version = GitVersionDescriptor(version=head_sha.commit_id, version_type='commit')
new_file_content_str = self.azure_devops_client.get_item(repository_id=self.repo_slug, try:
path=file, new_file_content_str = self.azure_devops_client.get_item(repository_id=self.repo_slug,
project=self.workspace_slug, path=file,
version_descriptor=version, project=self.workspace_slug,
download=False, version_descriptor=version,
include_content=True) download=False,
include_content=True)
new_file_content_str = new_file_content_str.content new_file_content_str = new_file_content_str.content
except Exception as e:
new_file_content_str = ""
edit_type = EDIT_TYPE.MODIFIED edit_type = EDIT_TYPE.MODIFIED
if diff_types[file] == 'add': if diff_types[file] == 'add':
@ -118,13 +121,16 @@ class AzureDevopsProvider:
edit_type = EDIT_TYPE.RENAMED edit_type = EDIT_TYPE.RENAMED
version = GitVersionDescriptor(version=base_sha.commit_id, version_type='commit') version = GitVersionDescriptor(version=base_sha.commit_id, version_type='commit')
original_file_content_str = self.azure_devops_client.get_item(repository_id=self.repo_slug, try:
original_file_content_str = self.azure_devops_client.get_item(repository_id=self.repo_slug,
path=file, path=file,
project=self.workspace_slug, project=self.workspace_slug,
version_descriptor=version, version_descriptor=version,
download=False, download=False,
include_content=True) include_content=True)
original_file_content_str = original_file_content_str.content original_file_content_str = original_file_content_str.content
except Exception as e:
original_file_content_str = ""
patch = load_large_diff(file, new_file_content_str, original_file_content_str) patch = load_large_diff(file, new_file_content_str, original_file_content_str)