Merge branch 'add-repo-url' into 'main'

[ADD] repos url git log!

See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!17
This commit is contained in:
LE GAL SYLVAIN 2022-07-12 15:25:12 +00:00
commit 0e44cad60d
8 changed files with 115 additions and 17 deletions

View File

@ -80,10 +80,10 @@ scripts/
...
src/
env_10.0/
debian_requirements.txt
extra_debian_requirements.txt
Dockerfile
odoo.cfg
python_requirements.txt
extra_python_requirements.txt
repos.yml
src/
env_11.0/
@ -124,12 +124,12 @@ modules.csv
Repo files are pre-generated. You can update them with your custom settings.
(custom branches, extra PRs, git shallow options, etc...)
- ``python_requirements.txt`` enumerates the list of extra python librairies
- ``extra_python_requirements.txt`` enumerates the list of extra python librairies
required to run the odoo instance.
The syntax should respect the ``pip install -r`` command.
(See : https://pip.pypa.io/en/stable/reference/requirements-file-format/)
- ``debian_requirements.txt`` enumerates the list of extra system librairies
- ``extra_debian_requirements.txt`` enumerates the list of extra system librairies
required to run the odoo instance.
- ``odoo.cfg`` file. Add here extra configuration required for your custom modules.
@ -144,6 +144,28 @@ extra repositories, or dependencies...
- In your repos.yml, preserve ``openupgrade`` and ``server-tools`` repositories
to have all the features of the librairies available.
## Command: ``pull-submodule``
**Prerequites:** init
if you already have a repos.yml file on github / gitlab, it can be convenient to
synchronize the repository, instead of copy past the ``repos.yml`` manually.
In that case, you can add extra values, in the ``config.yml`` file in the section
```
odoo_version_settings:
12.0:
repo_url: url_of_the_repo_that_contains_a_repos_yml_file
repo_branch: 12.0
repo_file_path: repos.yml
```
then run following command :
```
odoo-openupgrade-wizard pull-submodule
```
## Command: ``get-code``
@ -156,7 +178,8 @@ odoo-openupgrade-wizard get-code
This command will simply get all the Odoo code required to run all the steps
for your migration with the ``gitaggregate`` tools.
The code is defined in the ``repos.yml`` of each sub folders.
The code is defined in the ``repos.yml`` of each environment folders. (or in the
directory ``repo_submodule`` if you use ``pull-submodule`` feature.)
**Note**
@ -178,10 +201,6 @@ odoo-openupgrade-wizard get-code --versions 10.0,11.0
This will build local docker images that will be used in the following steps.
This script will pull official odoo docker images, defined in the ``Dockerfile`` of
each folder, and build a custom images on top the official one, installing inside
custom librairies defined in ``debian_requirements.txt``, ``python_requirements.txt``.
At this end of this step executing the following command should show a docker image per version.

View File

@ -23,6 +23,7 @@ from odoo_openupgrade_wizard.cli.cli_generate_module_analysis import (
from odoo_openupgrade_wizard.cli.cli_get_code import get_code
from odoo_openupgrade_wizard.cli.cli_init import init
from odoo_openupgrade_wizard.cli.cli_install_from_csv import install_from_csv
from odoo_openupgrade_wizard.cli.cli_pull_submodule import pull_submodule
from odoo_openupgrade_wizard.cli.cli_run import run
from odoo_openupgrade_wizard.cli.cli_upgrade import upgrade
from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
@ -116,5 +117,6 @@ main.add_command(generate_module_analysis)
main.add_command(get_code)
main.add_command(init)
main.add_command(install_from_csv)
main.add_command(pull_submodule)
main.add_command(run)
main.add_command(upgrade)

View File

@ -4,7 +4,10 @@ from odoo_openupgrade_wizard.cli.cli_options import (
get_odoo_versions_from_options,
versions_options,
)
from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
from odoo_openupgrade_wizard.tools.tools_odoo import (
get_odoo_env_path,
get_repo_file_path,
)
from odoo_openupgrade_wizard.tools.tools_system import git_aggregate
@ -24,5 +27,5 @@ def get_code(ctx, versions, jobs):
for odoo_version in get_odoo_versions_from_options(ctx, versions):
folder_path = get_odoo_env_path(ctx, odoo_version)
repo_file_path = folder_path / "repos.yml"
repo_file_path = get_repo_file_path(ctx, odoo_version)
git_aggregate(folder_path, repo_file_path, jobs)

View File

@ -0,0 +1,51 @@
import click
from loguru import logger
from odoo_openupgrade_wizard.cli.cli_options import (
get_odoo_versions_from_options,
versions_options,
)
from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
from odoo_openupgrade_wizard.tools.tools_system import execute_check_output
@click.command()
@versions_options
@click.pass_context
def pull_submodule(ctx, versions):
"""Pull submodule that contains repos.yml file, if define in config.yml"""
for odoo_version in get_odoo_versions_from_options(ctx, versions):
version_cfg = (
ctx.obj["config"]["odoo_version_settings"][odoo_version] or {}
)
if version_cfg.get("repo_url"):
logger.info(
f"Pull repos.yml from git repository"
f" for version {odoo_version} ..."
)
submodule_path = (
get_odoo_env_path(ctx, odoo_version) / "repo_submodule"
)
if not submodule_path.exists():
execute_check_output(
[
"git",
"submodule",
"add",
"-b",
str(version_cfg["repo_branch"]),
version_cfg["repo_url"],
submodule_path,
]
)
else:
execute_check_output(
["git", "pull", "origin", str(version_cfg["repo_branch"])],
working_directory=submodule_path,
)
else:
logger.warning(
f"No submodule configuration found"
f" for version {odoo_version} ..."
)

View File

@ -17,7 +17,6 @@ odoo_versions:
odoo_version_settings:
{%- for odoo_version in odoo_versions %}
{{odoo_version}}:
repo_url: False
{%- endfor %}

View File

@ -24,12 +24,32 @@ from odoo_openupgrade_wizard.tools.tools_postgres import get_postgres_container
from odoo_openupgrade_wizard.tools.tools_system import get_script_folder
def get_repo_file_path(ctx, odoo_version: float) -> Path:
"""return the relative path of the repos.yml file
of a given odoo version"""
repo_file = False
# Check if submodule path exists
version_cfg = (
ctx.obj["config"]["odoo_version_settings"][odoo_version] or {}
)
submodule_path = get_odoo_env_path(ctx, odoo_version) / "repo_submodule"
if submodule_path.exists():
repo_file = submodule_path / version_cfg["repo_file_path"]
if repo_file.exists():
return repo_file
else:
logger.warning(f"Unable to find the repo file {repo_file}.")
repo_file = get_odoo_env_path(ctx, odoo_version) / Path("repos.yml")
if not repo_file.exists():
raise Exception(f"Unable to find the repo file {repo_file}.")
return repo_file
def get_odoo_addons_path(
ctx, root_path: Path, migration_step: dict, execution_context: str = False
) -> str:
repo_file = get_odoo_env_path(ctx, migration_step["version"]) / Path(
"repos.yml"
)
repo_file = get_repo_file_path(ctx, migration_step["version"])
base_module_folder = get_base_module_folder(migration_step)
stream = open(repo_file, "r")
data = yaml.safe_load(stream)

View File

@ -1,5 +1,6 @@
import argparse
import os
import subprocess
from pathlib import Path
import importlib_resources
@ -104,3 +105,8 @@ def git_aggregate(folder_path: Path, config_path: Path, jobs: int):
def get_local_user_id():
return os.getuid()
def execute_check_output(args_list, working_directory=False):
logger.debug("Execute %s" % " ".join(args_list))
subprocess.check_output(args_list, cwd=working_directory)

View File

@ -15,9 +15,7 @@ odoo_versions:
odoo_version_settings:
14.0:
repo_url: False
15.0:
repo_url: False
migration_steps: