New hook 'destroyed-symlinks' to detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to; move zsplit to util

This commit is contained in:
Mikhail Khvoinitsky 2020-08-02 21:25:07 +03:00 committed by Anthony Sottile
parent 14e9f0e512
commit 1e87d59a2d
9 changed files with 204 additions and 18 deletions

View file

@ -8,18 +8,11 @@ from typing import Sequence
from typing import Set
from pre_commit_hooks.util import cmd_output
from pre_commit_hooks.util import zsplit
EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7'))
def zsplit(s: str) -> List[str]:
s = s.strip('\0')
if s:
return s.split('\0')
else:
return []
def check_executables(paths: List[str]) -> int:
if sys.platform == 'win32': # pragma: win32 cover
return _check_git_filemode(paths)