jumanjihouse / pre-commit-hooks

git pre-commit hooks that work with http://pre-commit.com/
MIT License
114 stars 52 forks source link

Some script hooks do not work on Windows #67

Closed MinerSebas closed 2 years ago

MinerSebas commented 4 years ago

When running pre-commit on Windows 10, the Hooks check-mailmap,forbid-binary,forbid-space-in-indent,git-check, git-dirty, and shellcheck all Report Executable /bin/sh not found:

$ pre-commit run -a
Detect if an email address needs to be added to mailmap.......................Failed
- hook id: check-mailmap
- exit code: 1

Executable `/bin/sh` not found

Forbid binaries...............................................................Failed
- hook id: forbid-binary
- exit code: 1

Executable `/bin/sh` not found

Forbid spaces in indentation..................................................Failed
- hook id: forbid-space-in-indent
- exit code: 1

Executable `/bin/sh` not found

Check for conflict markers and core.whitespace errors.........................Failed
- hook id: git-check
- exit code: 1

Executable `/bin/sh` not found

Check if the git tree is dirty................................................Failed
- hook id: git-dirty
- exit code: 1

Executable `/bin/sh` not found

Test shell scripts with shellcheck............................................Failed
- hook id: shellcheck
- exit code: 1

Executable `/bin/sh` not found

When changing their Shebang to #!/usr/bin/env bash, they work correctly:

$ pre-commit run -a
Detect if an email address needs to be added to mailmap.......................Passed
Forbid binaries...............................................................Failed
- hook id: forbid-binary
- exit code: 1

[ERROR] demo.gif appears to be a binary file
[ERROR] addons/gut/fonts/CourierPrime-Italic.ttf appears to be a binary file
[ERROR] addons/gut/fonts/AnonymousPro-BoldItalic.ttf appears to be a binary file
[ERROR] addons/gut/fonts/CourierPrime-Bold.ttf appears to be a binary file
[ERROR] addons/gut/fonts/AnonymousPro-Bold.ttf appears to be a binary file
[ERROR] addons/gut/fonts/LobsterTwo-Bold.ttf appears to be a binary file
[ERROR] addons/gut/fonts/LobsterTwo-Regular.ttf appears to be a binary file
[ERROR] addons/gut/fonts/AnonymousPro-Italic.ttf appears to be a binary file
[ERROR] addons/gut/source_code_pro.fnt appears to be a binary file
[ERROR] addons/gut/fonts/CourierPrime-Regular.ttf appears to be a binary file
[ERROR] addons/gut/fonts/LobsterTwo-Italic.ttf appears to be a binary file
[ERROR] addons/gut/icon.png appears to be a binary file
[ERROR] addons/gut/fonts/CourierPrime-BoldItalic.ttf appears to be a binary file
[ERROR] addons/gut/fonts/AnonymousPro-Regular.ttf appears to be a binary file
[ERROR] addons/gut/fonts/LobsterTwo-BoldItalic.ttf appears to be a binary file
[ERROR] icon.png appears to be a binary file

Forbid spaces in indentation..................................................Failed
- hook id: forbid-space-in-indent
- exit code: 1

file_format.sh

Found space(s) within indentation in the above file(s).
addons/gut/gut_plugin.gd

Found space(s) within indentation in the above file(s).
gut.sh

Found space(s) within indentation in the above file(s).
.gutconfig.json
test/integration/test_hello_world.gd

Found space(s) within indentation in the above file(s).
test/unit/test_hello_world.gd

Found space(s) within indentation in the above file(s).

Check for conflict markers and core.whitespace errors.........................Passed
Check if the git tree is dirty................................................Failed
- hook id: git-dirty
- exit code: 1

M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml
M  .pre-commit-config.yaml

Test shell scripts with shellcheck............................................Failed
- hook id: shellcheck
- exit code: 127

C:\Users\scher\.cache\pre-commit\repo0l4uhq52\pre_commit_hooks\shellcheck: line 13: shellcheck: command not found
Kurt-von-Laven commented 2 years ago

I ran into this as well. Thanks for the explanation.

serv-inc commented 2 years ago

@jumanjiman : thanks for the repo. This problem keeps the shell parts from working in windows. Is there anything keeping you from merging the PR ?