pre-commit-hooks: check-executables-have-shebangs not correct on windows

does not seem to work right on windows

i am dealing with a primarily linux / python project but on a windows machine.

i have set git config core.filemode false

i created a new file and stage and i verify that filemode is 644:

>git ls-files -s newfile.py
100644 3edd36f71bf2081c70a0eaf39dec6980d0a9f791 0       newfile.py

but hook still fails

hookid: check-executables-have-shebangs

newfile.py: marked executable but has no (or invalid) shebang!
  If it isn't supposed to be executable, try: chmod -x newfile.py
  If it is supposed to be executable, double-check its shebang.

why is this file causing error?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I bypassed the issue by running this command in my Windows Powershell.

git update-index --chmod=+x .\filename.py

so perhaps it could look at what it set in core.filemode

if false that means “can’t trust os filemode”

so if false, then look at git filemode; otherwise, os is fine?

hmmm yes and no – most of the scripts work standalone – but I could see handling it just as the git mode (perhaps just on windows?)

windows unfortunately considers all files as os.X_OK (since windows doesn’t really have a concept of non-executable files)

this check is really only designed for posix, we could maybe change it to just do nothing on windows? what do you think about that?