mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Remove pre_commit.five
This commit is contained in:
@@ -3,10 +3,9 @@ import os.path
|
||||
import sys
|
||||
import traceback
|
||||
from typing import Generator
|
||||
from typing import Union
|
||||
from typing import Optional
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import five
|
||||
from pre_commit import output
|
||||
from pre_commit.store import Store
|
||||
|
||||
@@ -15,25 +14,24 @@ class FatalError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def _to_bytes(exc: BaseException) -> bytes:
|
||||
return str(exc).encode()
|
||||
|
||||
|
||||
def _log_and_exit(msg: str, exc: BaseException, formatted: str) -> None:
|
||||
error_msg = b''.join((
|
||||
five.to_bytes(msg), b': ',
|
||||
five.to_bytes(type(exc).__name__), b': ',
|
||||
_to_bytes(exc),
|
||||
msg.encode(), b': ',
|
||||
type(exc).__name__.encode(), b': ',
|
||||
str(exc).encode(),
|
||||
))
|
||||
output.write_line(error_msg)
|
||||
output.write_line_b(error_msg)
|
||||
store = Store()
|
||||
log_path = os.path.join(store.directory, 'pre-commit.log')
|
||||
output.write_line(f'Check the log at {log_path}')
|
||||
|
||||
with open(log_path, 'wb') as log:
|
||||
def _log_line(s: Union[None, str, bytes] = None) -> None:
|
||||
def _log_line(s: Optional[str] = None) -> None:
|
||||
output.write_line(s, stream=log)
|
||||
|
||||
def _log_line_b(s: Optional[bytes] = None) -> None:
|
||||
output.write_line_b(s, stream=log)
|
||||
|
||||
_log_line('### version information')
|
||||
_log_line()
|
||||
_log_line('```')
|
||||
@@ -50,7 +48,7 @@ def _log_and_exit(msg: str, exc: BaseException, formatted: str) -> None:
|
||||
_log_line('### error information')
|
||||
_log_line()
|
||||
_log_line('```')
|
||||
_log_line(error_msg)
|
||||
_log_line_b(error_msg)
|
||||
_log_line('```')
|
||||
_log_line()
|
||||
_log_line('```')
|
||||
|
||||
Reference in New Issue
Block a user