◐ Shell
clean mode source ↗

Suggest usable call when executable files lack shebang on Windows by pujitm · Pull Request #689 · pre-commit/pre-commit-hooks

Conversation

@pujitm

Resolves #686

Some of the executable error messages suggest using chmod +/-x to toggle the executable bits. This works fine on *nix, but not on windows, and the results range from 'command not found' to doing nothing at all.

Eg:

f'`chmod -x {shlex.quote(path)}`\n'

Instead, this should recommend git add --chmod=+/-x somepath when the hook detects it's running on windows.

@pujitm

asottile

@Kurt-von-Laven

This comment has been minimized.

@asottile

This comment has been minimized.

asottile

Comment on lines +66 to +67

f'`chmod -x {shlex.quote(path)}`\n'
f'`{"git add --chmod=-x" if is_windows else "chmod -x"} {shlex.quote(path)}`\n'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I mean, without having any branching logic just write:

"chmod -x ..."
" if on windows you may also need to ..."

asottile

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jmerdich added a commit to jmerdich/pre-commit-hooks that referenced this pull request

Dec 13, 2021
Follow-up for pre-commit#686 and pre-commit#689.

The previous change resolved when a file was executable but lacked
a shebang, but not vice-versa.