From 9281d6b572eb9f912070879244298787cef5e998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Thu, 5 Jan 2023 12:28:59 +0100 Subject: [PATCH 1/3] [FIX] repository_name case insensitive --- odoo_openupgrade_wizard/templates/analysis.html.j2 | 4 ++-- odoo_openupgrade_wizard/tools/tools_odoo_module.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/odoo_openupgrade_wizard/templates/analysis.html.j2 b/odoo_openupgrade_wizard/templates/analysis.html.j2 index 0bb3066..4e59190 100644 --- a/odoo_openupgrade_wizard/templates/analysis.html.j2 +++ b/odoo_openupgrade_wizard/templates/analysis.html.j2 @@ -37,8 +37,8 @@ OCA - {{ analysis.get_module_qty('OCA') }} - {{ analysis.workload_hour_text('OCA') }} + {{ analysis.get_module_qty('oca') }} + {{ analysis.workload_hour_text('oca') }} Custom diff --git a/odoo_openupgrade_wizard/tools/tools_odoo_module.py b/odoo_openupgrade_wizard/tools/tools_odoo_module.py index b248b99..d982a7f 100644 --- a/odoo_openupgrade_wizard/tools/tools_odoo_module.py +++ b/odoo_openupgrade_wizard/tools/tools_odoo_module.py @@ -323,8 +323,8 @@ class OdooModule(object): self.module_type = "not_found" elif repository_name == "odoo/odoo": self.module_type = "odoo" - elif repository_name.startswith("OCA"): - self.module_type = "OCA" + elif repository_name.startswith("oca"): + self.module_type = "oca" else: self.module_type = "custom" @@ -355,7 +355,7 @@ class OdooModule(object): """Search the module in all the addons path of a given version and return the addon path of the module, or False if not found. For exemple find_repository(ctx, 'web_responsive', 12.0) - '/PATH_TO_LOCAL_ENV/src/OCA/web' + '/PATH_TO_LOCAL_ENV/src/oca/web' """ # Try to find the repository that contains the module main_path = get_odoo_env_path(ctx, current_version) @@ -375,7 +375,7 @@ class OdooModule(object): """Given an addons path that contains odoo modules in a folder that has been checkouted via git, return a repository name with the following format org_name/repo_name. - For exemple 'OCA/web' or 'odoo/odoo' + For exemple 'oca/web' or 'odoo/odoo' """ # TODO, make the code cleaner and more resiliant # for the time being, the code will fail for @@ -406,7 +406,9 @@ class OdooModule(object): repository_name = repo.remotes[0].url.replace( "https://github.com/", "" ) - if repository_name.lower() == "oca/openupgrade": + # Standardize all repository_name to lower case + repository_name = repository_name.lower() + if repository_name == "oca/openupgrade": return "odoo/odoo" else: return repository_name @@ -421,7 +423,7 @@ class OdooModule(object): if self.module_type != other.module_type: if self.module_type == "odoo": return True - elif self.module_type == "OCA" and other.module_type in [ + elif self.module_type == "oca" and other.module_type in [ "custom", "not_found", ]: From 8c55892d53f9eab0471fd2e401943a81642b6fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 10 Jan 2023 19:51:20 +0100 Subject: [PATCH 2/3] [FIX] estimate-workload: not_found module not categorized --- odoo_openupgrade_wizard/templates/analysis.html.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo_openupgrade_wizard/templates/analysis.html.j2 b/odoo_openupgrade_wizard/templates/analysis.html.j2 index 4e59190..6359a2f 100644 --- a/odoo_openupgrade_wizard/templates/analysis.html.j2 +++ b/odoo_openupgrade_wizard/templates/analysis.html.j2 @@ -47,7 +47,7 @@ Not Found - {{ analysis.get_module_qty('custom') }} + {{ analysis.get_module_qty('not_found') }}   From a5dcd8fdcc0a57ba42f366fd40eb5a71feb4bfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 10 Jan 2023 19:52:51 +0100 Subject: [PATCH 3/3] [IMP] module repository_name detection Some repository may have multiples remotes. This tries to find the main remote when possible. --- .../tools/tools_odoo_module.py | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/odoo_openupgrade_wizard/tools/tools_odoo_module.py b/odoo_openupgrade_wizard/tools/tools_odoo_module.py index d982a7f..15bd050 100644 --- a/odoo_openupgrade_wizard/tools/tools_odoo_module.py +++ b/odoo_openupgrade_wizard/tools/tools_odoo_module.py @@ -403,15 +403,36 @@ class OdooModule(object): except InvalidGitRepositoryError as err: logger.critical(f"{path} is not a Git Repository.") raise err - repository_name = repo.remotes[0].url.replace( - "https://github.com/", "" + github_url_prefixes = ( + "https://github.com/", + "git@github.com:", ) - # Standardize all repository_name to lower case - repository_name = repository_name.lower() - if repository_name == "oca/openupgrade": + repository_names = [] + for remote in repo.remotes: + # Standardize all repository_name to lower case + repository_name = remote.url.lower() + for github_url_prefix in github_url_prefixes: + repository_name = repository_name.replace( + github_url_prefix, "" + ) + if repository_name.endswith(".git"): + repository_name = repository_name[: -len(".git")] + repository_names.append(repository_name) + # find main repository_name + main_repository_name = next( + ( + repo_name + for repo_name in repository_names + if repo_name.startswith("oca") + ), + None, + ) + if not main_repository_name: + main_repository_name = repository_names[0] + if main_repository_name == "oca/openupgrade": return "odoo/odoo" else: - return repository_name + return main_repository_name def __eq__(self, other): if isinstance(other, str):