mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
use_filesnames_file
This commit is contained in:
parent
0252908c27
commit
47d0e05d09
5 changed files with 34 additions and 0 deletions
|
|
@ -128,6 +128,7 @@ MANIFEST_HOOK_DICT = cfgv.Map(
|
|||
cfgv.Optional('always_run', cfgv.check_bool, False),
|
||||
cfgv.Optional('fail_fast', cfgv.check_bool, False),
|
||||
cfgv.Optional('pass_filenames', cfgv.check_bool, True),
|
||||
cfgv.Optional('use_filesnames_file', cfgv.check_bool, False),
|
||||
cfgv.Optional('description', cfgv.check_string, ''),
|
||||
cfgv.Optional('language_version', cfgv.check_string, C.DEFAULT),
|
||||
cfgv.Optional('log_file', cfgv.check_string, ''),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import logging
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import unicodedata
|
||||
from collections.abc import Generator
|
||||
|
|
@ -187,6 +188,11 @@ def _run_single_hook(
|
|||
|
||||
if not hook.pass_filenames:
|
||||
filenames = ()
|
||||
elif hook.use_filesnames_file:
|
||||
filenames_file = tempfile.NamedTemporaryFile("w+")
|
||||
filenames_file.write("\n".join(filenames))
|
||||
filenames = (f"@{filenames_file}",)
|
||||
|
||||
time_before = time.monotonic()
|
||||
language = languages[hook.language]
|
||||
with language.in_env(hook.prefix, hook.language_version):
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class Hook(NamedTuple):
|
|||
always_run: bool
|
||||
fail_fast: bool
|
||||
pass_filenames: bool
|
||||
use_filesnames_file: bool
|
||||
description: str
|
||||
language_version: str
|
||||
log_file: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue