Commit graph

10 commits

Author SHA1 Message Date
Yann Leprince
741d95128b 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).
2021-07-23 11:28:14 +02:00
Ville Skyttä
9e7cd9f13a Refactor check_executables_have_shebangs for git ls-files reuse 2021-05-04 18:45:42 -07:00
Ville Skyttä
dae0cbd2fa check_executables_have_shebangs: avoid unneeded shebang reads on win32 2021-01-08 16:22:33 +02:00
Mikhail Khvoinitsky
1e87d59a2d 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 2020-11-18 11:45:05 -08:00
Timothée Mazzucotelli
4faed34fbc Fix parsing of git output with unusual characters
On Windows, all files are "executable".
Therefore, to know if a file is supposed to be executed,
we check how its attributes were recorded by git:
we run a `git ls-files` command in a subprocess.

By default, this command outputs information
on multiple lines (file and their data separated by newlines).
When a file contains an unusual character,
the character is escaped with an integer sequence
(such as `\303\261`), and git wraps the whole filename
in double-quotes because of the backslashes.
It breaks the current code because we try to open
the filename containing the double-quotes:
it doesn't exist, of course.

Instead of trying to fix this special case by removing
the double-quotes, and breaking other cases
(a double-quote is a valid filename character on Linux),
we tell git to separate each item with the null character `\0`
instead of a new line `\n`, with the option `-z`.
With this option, git doesn't escape unusual characters
with integer sequence, so the output is fixed, and we
parse it by splitting on `\0` instead of `\n`.

Fixes #508.
2020-07-30 11:58:24 -07:00
Max Rozentsveyg
5195ba3449 Check git mode on Windows 2020-05-18 16:11:10 -07:00
Anthony Sottile
f5c42a050b pre-commit-hooks: python3.6+ 2020-02-05 11:22:18 -08:00
Anthony Sottile
4575652bd2 Use default flake8 config 2019-02-11 19:56:15 -08:00
Anthony Sottile
030bfac7e4 Apply typing to all of pre-commit-hooks 2019-01-31 20:09:15 -08:00
Chris Kuehl
13991f09d2 Add a checker for executables without shebangs 2017-07-02 21:14:25 -07:00