Skip to content

Commit 2cbabf9

Browse files
Check Git core.fileMode rather than infer from OS.
There was already a guard preventing the check-executables-have-shebangs hook from raising false positives on win32 by looking up the Git file mode rather than relying on the file mode in the file system. Git already automatically probes the file system for executable bit support. Leverage Git's core.fileMode config variable to prevent false positives on all file systems that don't track executable bits.
1 parent f5c2675 commit 2cbabf9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pre_commit_hooks/check_executables_have_shebangs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616

1717
def check_executables(paths: list[str]) -> int:
18-
if sys.platform == 'win32': # pragma: win32 cover
18+
fs_tracks_executable_bit = cmd_output(
19+
'git', 'config', 'core.fileMode', retcode=None,
20+
).strip()
21+
if fs_tracks_executable_bit == 'false': # pragma: win32 cover
1922
return _check_git_filemode(paths)
2023
else: # pragma: win32 no cover
2124
retv = 0

0 commit comments

Comments
 (0)