mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Fix false positives of check-executables-have-shebangs
check-executables-have-shebangs needs to check the actual file mode known to Git and avoid relying only on the filesystem permissions, because some filesystems force the executable bit on every file (e.g. fat32 on Linux).
This commit is contained in:
parent
d0d9883648
commit
741d95128b
1 changed files with 5 additions and 10 deletions
|
|
@ -16,16 +16,11 @@ EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7'))
|
||||||
|
|
||||||
|
|
||||||
def check_executables(paths: List[str]) -> int:
|
def check_executables(paths: List[str]) -> int:
|
||||||
if sys.platform == 'win32': # pragma: win32 cover
|
# Even if this hook is configured to be called only on files flagged
|
||||||
return _check_git_filemode(paths)
|
# executable by identify, we must check the real filemode known to Git
|
||||||
else: # pragma: win32 no cover
|
# because some filesystems force the executable bit (e.g. fat32 under
|
||||||
retv = 0
|
# Linux).
|
||||||
for path in paths:
|
return _check_git_filemode(paths)
|
||||||
if not has_shebang(path):
|
|
||||||
_message(path)
|
|
||||||
retv = 1
|
|
||||||
|
|
||||||
return retv
|
|
||||||
|
|
||||||
|
|
||||||
class GitLsFile(NamedTuple):
|
class GitLsFile(NamedTuple):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue