From 0f97b4431bd15a420ef13c529cf5afca11d953ba Mon Sep 17 00:00:00 2001 From: "acebots-ai[bot]" <161142084+acebots-ai[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:07:17 +0000 Subject: [PATCH 1/4] Update acedev/service/git_repository.py --- acedev/service/git_repository.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/acedev/service/git_repository.py b/acedev/service/git_repository.py index 21e718b..aa71119 100644 --- a/acedev/service/git_repository.py +++ b/acedev/service/git_repository.py @@ -33,8 +33,21 @@ def __init__(self, github_repo: Repository) -> None: self.github_repo = github_repo self.default_branch = github_repo.default_branch self.full_name = github_repo.full_name - self.language = (github_repo.language or - max(github_repo.get_languages(), key=github_repo.get_languages().get)).lower() + self.language = self.determine_default_language(github_repo) + + @staticmethod + def determine_default_language(github_repo: Repository) -> Optional[str]: + if github_repo.language: + return github_repo.language.lower() + elif github_repo.languages and len(github_repo.languages) > 0: + # Assuming github_repo.languages is a list or dict of languages + # If it's a dict, take the most used language as default + if isinstance(github_repo.languages, dict): + return max(github_repo.languages, key=github_repo.languages.get).lower() + # If it's a list, take the first language as default + elif isinstance(github_repo.languages, list): + return github_repo.languages[0].lower() + return None def __repr__(self) -> str: return f"Project({self.full_name})" From 53be55e67188a531d278f615cf9342c083343f54 Mon Sep 17 00:00:00 2001 From: "acebots-ai[bot]" <161142084+acebots-ai[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:14:05 +0000 Subject: [PATCH 2/4] Update acedev/service/git_repository.py --- acedev/service/git_repository.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/acedev/service/git_repository.py b/acedev/service/git_repository.py index aa71119..e47e6cc 100644 --- a/acedev/service/git_repository.py +++ b/acedev/service/git_repository.py @@ -37,16 +37,9 @@ def __init__(self, github_repo: Repository) -> None: @staticmethod def determine_default_language(github_repo: Repository) -> Optional[str]: - if github_repo.language: - return github_repo.language.lower() - elif github_repo.languages and len(github_repo.languages) > 0: - # Assuming github_repo.languages is a list or dict of languages - # If it's a dict, take the most used language as default - if isinstance(github_repo.languages, dict): - return max(github_repo.languages, key=github_repo.languages.get).lower() - # If it's a list, take the first language as default - elif isinstance(github_repo.languages, list): - return github_repo.languages[0].lower() + languages = github_repo.get_languages() + if languages: + return max(languages, key=languages.get).lower() return None def __repr__(self) -> str: From cdee4d85a75679cc85926027a726de7190e7a266 Mon Sep 17 00:00:00 2001 From: "acebots-ai[bot]" <161142084+acebots-ai[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:22:53 +0000 Subject: [PATCH 3/4] Update acedev/service/git_repository.py --- acedev/service/git_repository.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/acedev/service/git_repository.py b/acedev/service/git_repository.py index e47e6cc..7982b63 100644 --- a/acedev/service/git_repository.py +++ b/acedev/service/git_repository.py @@ -38,8 +38,9 @@ def __init__(self, github_repo: Repository) -> None: @staticmethod def determine_default_language(github_repo: Repository) -> Optional[str]: languages = github_repo.get_languages() - if languages: - return max(languages, key=languages.get).lower() + if not languages: + return None + return max(languages, key=languages.get).lower() return None def __repr__(self) -> str: From f21be7f2bcd722898e9c2f14a04e969ac704029d Mon Sep 17 00:00:00 2001 From: "acebots-ai[bot]" <161142084+acebots-ai[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:40:08 +0000 Subject: [PATCH 4/4] Update acedev/service/git_repository.py --- acedev/service/git_repository.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/acedev/service/git_repository.py b/acedev/service/git_repository.py index 7982b63..15207fe 100644 --- a/acedev/service/git_repository.py +++ b/acedev/service/git_repository.py @@ -38,8 +38,6 @@ def __init__(self, github_repo: Repository) -> None: @staticmethod def determine_default_language(github_repo: Repository) -> Optional[str]: languages = github_repo.get_languages() - if not languages: - return None return max(languages, key=languages.get).lower() return None