mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
show color in hook outputs when attached to a tty
This commit is contained in:
parent
c8620f35e1
commit
7c3404ef1f
27 changed files with 200 additions and 76 deletions
|
|
@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
|||
import multiprocessing
|
||||
import os
|
||||
import random
|
||||
import shlex
|
||||
|
||||
import six
|
||||
|
||||
|
|
@ -25,10 +24,6 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
|
|||
return '{}-{}'.format(ENVIRONMENT_DIR, language_version)
|
||||
|
||||
|
||||
def to_cmd(hook):
|
||||
return tuple(shlex.split(hook.entry)) + tuple(hook.args)
|
||||
|
||||
|
||||
def assert_version_default(binary, version):
|
||||
if version != C.DEFAULT:
|
||||
raise AssertionError(
|
||||
|
|
@ -83,8 +78,9 @@ def _shuffled(seq):
|
|||
return seq
|
||||
|
||||
|
||||
def run_xargs(hook, cmd, file_args):
|
||||
def run_xargs(hook, cmd, file_args, **kwargs):
|
||||
# Shuffle the files so that they more evenly fill out the xargs partitions,
|
||||
# but do it deterministically in case a hook cares about ordering.
|
||||
file_args = _shuffled(file_args)
|
||||
return xargs(cmd, file_args, target_concurrency=target_concurrency(hook))
|
||||
kwargs['target_concurrency'] = target_concurrency(hook)
|
||||
return xargs(cmd, file_args, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue