diff --git a/NEWS.rst b/NEWS.rst index 5b25b6abd29eb0ae38272059ae96ab1eec4ebd29_TkVXUy5yc3Q=..161fb138647eb8222fc569766ddb45117a38c78e_TkVXUy5yc3Q= 100644 --- 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 index 5b25b6abd29eb0ae38272059ae96ab1eec4ebd29_b2Rvb19zY3JpcHRzL2RvY2tlcl9ibGFjay5weQ==..161fb138647eb8222fc569766ddb45117a38c78e_b2Rvb19zY3JpcHRzL2RvY2tlcl9ibGFjay5weQ== 100644 --- a/odoo_scripts/docker_black.py +++ b/odoo_scripts/docker_black.py @@ -12,5 +12,5 @@ from .docker_client import DockerClient from .parsing import apply, basic_parser -__version__ = "2.0.0" +__version__ = "2.1.0" __date__ = "2022-03-03" @@ -16,5 +16,5 @@ __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,8 +84,11 @@ "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")) @@ -88,10 +91,13 @@ 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, { @@ -92,8 +98,8 @@ _logger.info("Running black in %s", path) return DockerClient.run( config.local_image, config.local_tag, { - "entrypoint": "black", + "entrypoint": "sh", "user": os.getuid(), @@ -99,5 +105,5 @@ "user": os.getuid(), - "command": command, + "command": ["-c", ";".join(command)], "volumes": volumes, "working_dir": path, "tty": True,