Merge branch 'fix-repository_name-case-estimate-workload' into 'main'
[FIX] repository_name Closes #30 and #24 See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!26
This commit is contained in:
commit
e35aa8d804
|
|
@ -37,8 +37,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>OCA</td>
|
<td>OCA</td>
|
||||||
<td>{{ analysis.get_module_qty('OCA') }}</td>
|
<td>{{ analysis.get_module_qty('oca') }}</td>
|
||||||
<td>{{ analysis.workload_hour_text('OCA') }}</td>
|
<td>{{ analysis.workload_hour_text('oca') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Custom</td>
|
<td>Custom</td>
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Not Found</td>
|
<td>Not Found</td>
|
||||||
<td>{{ analysis.get_module_qty('custom') }}</td>
|
<td>{{ analysis.get_module_qty('not_found') }}</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -323,8 +323,8 @@ class OdooModule(object):
|
||||||
self.module_type = "not_found"
|
self.module_type = "not_found"
|
||||||
elif repository_name == "odoo/odoo":
|
elif repository_name == "odoo/odoo":
|
||||||
self.module_type = "odoo"
|
self.module_type = "odoo"
|
||||||
elif repository_name.startswith("OCA"):
|
elif repository_name.startswith("oca"):
|
||||||
self.module_type = "OCA"
|
self.module_type = "oca"
|
||||||
else:
|
else:
|
||||||
self.module_type = "custom"
|
self.module_type = "custom"
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ class OdooModule(object):
|
||||||
"""Search the module in all the addons path of a given version
|
"""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.
|
and return the addon path of the module, or False if not found.
|
||||||
For exemple find_repository(ctx, 'web_responsive', 12.0)
|
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
|
# Try to find the repository that contains the module
|
||||||
main_path = get_odoo_env_path(ctx, current_version)
|
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
|
"""Given an addons path that contains odoo modules in a folder
|
||||||
that has been checkouted via git, return a repository name with the
|
that has been checkouted via git, return a repository name with the
|
||||||
following format org_name/repo_name.
|
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
|
# TODO, make the code cleaner and more resiliant
|
||||||
# for the time being, the code will fail for
|
# for the time being, the code will fail for
|
||||||
|
|
@ -403,13 +403,36 @@ class OdooModule(object):
|
||||||
except InvalidGitRepositoryError as err:
|
except InvalidGitRepositoryError as err:
|
||||||
logger.critical(f"{path} is not a Git Repository.")
|
logger.critical(f"{path} is not a Git Repository.")
|
||||||
raise err
|
raise err
|
||||||
repository_name = repo.remotes[0].url.replace(
|
github_url_prefixes = (
|
||||||
"https://github.com/", ""
|
"https://github.com/",
|
||||||
|
"git@github.com:",
|
||||||
)
|
)
|
||||||
if repository_name.lower() == "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"
|
return "odoo/odoo"
|
||||||
else:
|
else:
|
||||||
return repository_name
|
return main_repository_name
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, str):
|
if isinstance(other, str):
|
||||||
|
|
@ -421,7 +444,7 @@ class OdooModule(object):
|
||||||
if self.module_type != other.module_type:
|
if self.module_type != other.module_type:
|
||||||
if self.module_type == "odoo":
|
if self.module_type == "odoo":
|
||||||
return True
|
return True
|
||||||
elif self.module_type == "OCA" and other.module_type in [
|
elif self.module_type == "oca" and other.module_type in [
|
||||||
"custom",
|
"custom",
|
||||||
"not_found",
|
"not_found",
|
||||||
]:
|
]:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user