mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
protection for no language
This commit is contained in:
parent
ea91a38541
commit
4fbe7d14b5
2 changed files with 9 additions and 0 deletions
|
|
@ -42,6 +42,11 @@ def sort_files_by_main_languages(languages: Dict, files: list):
|
||||||
files_sorted = []
|
files_sorted = []
|
||||||
rest_files = {}
|
rest_files = {}
|
||||||
|
|
||||||
|
# if no languages detected, put all files in the "Other" category
|
||||||
|
if not languages:
|
||||||
|
files_sorted = [({"language": "Other", "files": list(files_filtered)})]
|
||||||
|
return files_sorted
|
||||||
|
|
||||||
main_extensions_flat = []
|
main_extensions_flat = []
|
||||||
for ext in main_extensions:
|
for ext in main_extensions:
|
||||||
main_extensions_flat.extend(ext)
|
main_extensions_flat.extend(ext)
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,10 @@ def get_main_pr_language(languages, files) -> str:
|
||||||
Get the main language of the commit. Return an empty string if cannot determine.
|
Get the main language of the commit. Return an empty string if cannot determine.
|
||||||
"""
|
"""
|
||||||
main_language_str = ""
|
main_language_str = ""
|
||||||
|
if not languages:
|
||||||
|
logging.info("No languages detected")
|
||||||
|
return main_language_str
|
||||||
|
|
||||||
try:
|
try:
|
||||||
top_language = max(languages, key=languages.get).lower()
|
top_language = max(languages, key=languages.get).lower()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue