mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Optimize Docker image pull
This commit is contained in:
parent
65175f3cf3
commit
7c64e47d93
2 changed files with 45 additions and 2 deletions
|
|
@ -23,9 +23,18 @@ def run_hook(
|
|||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]: # pragma: win32 no cover
|
||||
cmd = docker_cmd(color=color) + lang_base.hook_cmd(entry, args)
|
||||
cmd = lang_base.hook_cmd(entry, args)
|
||||
|
||||
# To prevent duplicate simultaneous image pull attempts in `run_xargs`, we
|
||||
# try to precache the Docker image by pulling it here first
|
||||
try:
|
||||
image_name = cmd[2 if cmd[0] == '--entrypoint' else 0]
|
||||
lang_base.setup_cmd(prefix, ('docker', 'pull', image_name))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return lang_base.run_xargs(
|
||||
cmd,
|
||||
docker_cmd(color=color) + cmd,
|
||||
file_args,
|
||||
require_serial=require_serial,
|
||||
color=color,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue