summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages/docker.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:09:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:09:11 +0000
commit7ac9b3f71ebacf2b35230a49f188a173127b3bdb (patch)
tree67ea3d6333c516cc6d972345c9948a572606752f /pre_commit/languages/docker.py
parentAdding upstream version 3.6.2. (diff)
downloadpre-commit-7ac9b3f71ebacf2b35230a49f188a173127b3bdb.tar.xz
pre-commit-7ac9b3f71ebacf2b35230a49f188a173127b3bdb.zip
Adding upstream version 3.7.0.upstream/3.7.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages/docker.py')
-rw-r--r--pre_commit/languages/docker.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pre_commit/languages/docker.py b/pre_commit/languages/docker.py
index 2632851..4de1d58 100644
--- a/pre_commit/languages/docker.py
+++ b/pre_commit/languages/docker.py
@@ -108,10 +108,15 @@ def get_docker_user() -> tuple[str, ...]: # pragma: win32 no cover
return ()
-def docker_cmd() -> tuple[str, ...]: # pragma: win32 no cover
+def get_docker_tty(*, color: bool) -> tuple[str, ...]: # pragma: win32 no cover # noqa: E501
+ return (('--tty',) if color else ())
+
+
+def docker_cmd(*, color: bool) -> tuple[str, ...]: # pragma: win32 no cover
return (
'docker', 'run',
'--rm',
+ *get_docker_tty(color=color),
*get_docker_user(),
# https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
# The `Z` option tells Docker to label the content with a private
@@ -139,7 +144,7 @@ def run_hook(
entry_tag = ('--entrypoint', entry_exe, docker_tag(prefix))
return lang_base.run_xargs(
- (*docker_cmd(), *entry_tag, *cmd_rest),
+ (*docker_cmd(color=color), *entry_tag, *cmd_rest),
file_args,
require_serial=require_serial,
color=color,