mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Improve the fsmonitor detection code
This commit is contained in:
parent
b7a86c87d2
commit
44ed39320c
1 changed files with 10 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import contextlib
|
||||
import logging
|
||||
import os.path
|
||||
import sys
|
||||
import time
|
||||
from typing import Generator
|
||||
|
||||
|
|
@ -49,8 +50,15 @@ def _intent_to_add_cleared() -> Generator[None, None, None]:
|
|||
|
||||
@contextlib.contextmanager
|
||||
def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]:
|
||||
if cmd_output('git', 'fsmonitor--daemon', 'status')[1].startswith('fsmonitor-daemon is watching'):
|
||||
logger.warning('The fsmonitor-daemon is running; a bug in the fsmonitor-daemon sometimes causes data loss when run with pre-commit.')
|
||||
if (
|
||||
(sys.platform == 'darwin' or sys.platform == 'win32')
|
||||
and os.path.exists('./.git/fsmonitor--daemon.ipc')
|
||||
and cmd_output('git', 'fsmonitor--daemon', 'status')[0] == 0
|
||||
):
|
||||
logger.warning(
|
||||
"The fsmonitor daemon is running; "
|
||||
"a bug in the fsmonitor daemon sometimes causes data loss "
|
||||
"when running with pre-commit.")
|
||||
|
||||
tree = cmd_output('git', 'write-tree')[1].strip()
|
||||
diff_cmd = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue