# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1680251284 -7200 # Fri Mar 31 10:28:04 2023 +0200 # Node ID 161fb138647eb8222fc569766ddb45117a38c78e # Parent 5b25b6abd29eb0ae38272059ae96ab1eec4ebd29 ✨ display black version diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,8 @@ docker_build_copy: when not in CI, default to copying packages and let the package be build in the image. +docker_black: also indicate version before running the command. + 20.1.0 ------ diff --git a/odoo_scripts/docker_black.py b/odoo_scripts/docker_black.py --- a/odoo_scripts/docker_black.py +++ b/odoo_scripts/docker_black.py @@ -12,9 +12,9 @@ from .docker_client import DockerClient from .parsing import apply, basic_parser -__version__ = "2.0.0" +__version__ = "2.1.0" __date__ = "2022-03-03" -__updated__ = "2023-02-21" +__updated__ = "2023-03-31" _logger = logging.getLogger(__name__) _BLACK_DEST = "black" @@ -61,7 +61,7 @@ return black(getattr(nmspc, _BLACK_DEST), nmspc.write, get_build_options(nmspc)) -def black(directory: str, write: bool, build_options): +def black(directory: str, write: bool, build_options, show_version: bool = True): """Run black""" config = Config() @@ -84,20 +84,26 @@ "mode": "rw" if write else "ro", } - command = ["."] + command = ["black", "."] + # The line was in a configuration file but not in modules in that Odoo 11 modules + # so this is still needed to avoid reformatting when forgetting to update the module + # configuration. if config.odoo_type == ODOO_11: command.extend(("--line-length", "79")) if not write: command.extend(("--check", "--diff")) + command = [" ".join(command)] + if show_version: + command.insert(0, "black --version") _logger.info("Running black in %s", path) return DockerClient.run( config.local_image, config.local_tag, { - "entrypoint": "black", + "entrypoint": "sh", "user": os.getuid(), - "command": command, + "command": ["-c", ";".join(command)], "volumes": volumes, "working_dir": path, "tty": True,