From 52ba2793cd67c4850c64aeda4f0bc0ee104f4eaa Mon Sep 17 00:00:00 2001 From: szecsip Date: Wed, 23 Aug 2023 15:59:49 +0000 Subject: [PATCH] modify get_main_pr_language to handle azuredevops provided language format --- pr_agent/git_providers/git_provider.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 2a891938..e8c1c8a8 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -1,3 +1,4 @@ +import logging from abc import ABC, abstractmethod from dataclasses import dataclass @@ -112,6 +113,8 @@ def get_main_pr_language(languages, files) -> str: # validate that the specific commit uses the main language extension_list = [] for file in files: + if isinstance(file, str): + file = FilePatchInfo(base_file=None, head_file=None, patch=None, filename=file) extension_list.append(file.filename.rsplit('.')[-1]) # get the most common extension @@ -133,10 +136,12 @@ def get_main_pr_language(languages, files) -> str: most_common_extension == 'scala' and top_language == 'scala' or \ most_common_extension == 'kt' and top_language == 'kotlin' or \ most_common_extension == 'pl' and top_language == 'perl' or \ - most_common_extension == 'swift' and top_language == 'swift': + most_common_extension == 'swift' and top_language == 'swift' or \ + most_common_extension == top_language: main_language_str = top_language - except Exception: + except Exception as e: + logging.info(e) pass return main_language_str