mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
parent
4bd6529c05
commit
f21257cdba
15 changed files with 69 additions and 31 deletions
|
|
@ -38,7 +38,7 @@ from pre_commit.languages import system
|
|||
# version - A version specified in the hook configuration or 'default'.
|
||||
# """
|
||||
#
|
||||
# def run_hook(hook, file_args, color):
|
||||
# def run_hook(hook, file_args, color, progress):
|
||||
# """Runs a hook and returns the returncode and output of running that
|
||||
# hook.
|
||||
#
|
||||
|
|
@ -46,6 +46,7 @@ from pre_commit.languages import system
|
|||
# hook - `Hook`
|
||||
# file_args - The files to be run
|
||||
# color - whether the hook should be given a pty (when supported)
|
||||
# progress - report progress as a float percentage
|
||||
#
|
||||
# Returns:
|
||||
# (returncode, output)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def docker_cmd(): # pragma: windows no cover
|
|||
)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color): # pragma: windows no cover
|
||||
def run_hook(hook, file_args, color, progress): # pragma: windows no cover
|
||||
assert_docker_available()
|
||||
# Rebuild the docker image in case it has gone missing, as many people do
|
||||
# automated cleanup of docker images.
|
||||
|
|
@ -106,4 +106,6 @@ def run_hook(hook, file_args, color): # pragma: windows no cover
|
|||
|
||||
entry_tag = ('--entrypoint', entry_exe, docker_tag(hook.prefix))
|
||||
cmd = docker_cmd() + entry_tag + cmd_rest
|
||||
return helpers.run_xargs(hook, cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ healthy = helpers.basic_healthy
|
|||
install_environment = helpers.no_install
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color): # pragma: windows no cover
|
||||
def run_hook(hook, file_args, color, progress): # pragma: windows no cover
|
||||
assert_docker_available()
|
||||
cmd = docker_cmd() + hook.cmd
|
||||
return helpers.run_xargs(hook, cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ def install_environment(prefix, version, additional_dependencies):
|
|||
rmtree(pkgdir)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color):
|
||||
def run_hook(hook, file_args, color, progress):
|
||||
with in_env(hook.prefix):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ def install_environment(
|
|||
)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color): # pragma: windows no cover
|
||||
def run_hook(hook, file_args, color, progress): # pragma: windows no cover
|
||||
with in_env(hook.prefix, hook.language_version):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -151,9 +151,11 @@ def py_interface(_dir, _make_venv):
|
|||
)
|
||||
return retcode == 0
|
||||
|
||||
def run_hook(hook, file_args, color):
|
||||
def run_hook(hook, file_args, color, progress):
|
||||
with in_env(hook.prefix, hook.language_version):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
||||
def install_environment(prefix, version, additional_dependencies):
|
||||
additional_dependencies = tuple(additional_dependencies)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ def install_environment(
|
|||
)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color): # pragma: windows no cover
|
||||
def run_hook(hook, file_args, color, progress): # pragma: windows no cover
|
||||
with in_env(hook.prefix, hook.language_version):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ def install_environment(prefix, version, additional_dependencies):
|
|||
)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color):
|
||||
def run_hook(hook, file_args, color, progress):
|
||||
with in_env(hook.prefix):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ healthy = helpers.basic_healthy
|
|||
install_environment = helpers.no_install
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color):
|
||||
def run_hook(hook, file_args, color, progress):
|
||||
cmd = hook.cmd
|
||||
cmd = (hook.prefix.path(cmd[0]),) + cmd[1:]
|
||||
return helpers.run_xargs(hook, cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ def install_environment(
|
|||
)
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color): # pragma: windows no cover
|
||||
def run_hook(hook, file_args, color, progress): # pragma: windows no cover
|
||||
with in_env(hook.prefix):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ healthy = helpers.basic_healthy
|
|||
install_environment = helpers.no_install
|
||||
|
||||
|
||||
def run_hook(hook, file_args, color):
|
||||
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
|
||||
def run_hook(hook, file_args, color, progress):
|
||||
return helpers.run_xargs(
|
||||
hook, hook.cmd, file_args, color=color, progress=progress,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue