-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add shellcheck and shfmt hooks * Fork shfmt pre-commit hook script * Improve usage of shfmt pre-commit hook script * Remove deprecated additional_dependencies for script hooks
- Loading branch information
1 parent
a1c3065
commit 34ed136
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "pre-commit-hooks"] | ||
path = submodule_pre_commit_hooks | ||
url = git@github.com:pre-commit/pre-commit-hooks.git | ||
[submodule "submodule_syntaqx_git_hooks"] | ||
path = submodule_syntaqx_git_hooks | ||
url = git@github.com:syntaqx/git-hooks.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# Original: https://github.com/syntaqx/git-hooks | ||
# Forked to auto-install shfmt and give better command suggestions | ||
# Original: https://github.com/jumanjihouse/pre-commit-hooks#shfmt | ||
# Forked to change runtime to /usr/bin/env on win10 | ||
set -eu | ||
|
||
readonly DEBUG=${DEBUG:-unset} | ||
if [ "${DEBUG}" != unset ]; then | ||
set -x | ||
fi | ||
|
||
if ! command -v shfmt >/dev/null 2>&1; then | ||
if command -v brew &>/dev/null; then | ||
brew install shfmt | ||
else | ||
>&2 echo 'This check needs shfmt from https://github.com/mvdan/sh/releases or brew install shfmt' | ||
fi | ||
exit 1 | ||
fi | ||
|
||
readonly cmd=(shfmt "$@") | ||
echo "[RUN] ${cmd[@]}" | ||
output="$("${cmd[@]}" 2>&1)" | ||
readonly output | ||
|
||
if [ -n "${output}" ]; then | ||
echo '[FAIL]' | ||
echo | ||
echo "${output}" | ||
echo | ||
echo 'The above files have style errors.' | ||
echo "Use 'shfmt -d $@' option to show diff." | ||
echo "Use 'shfmt -w $@' option to write (autocorrect)." | ||
exit 1 | ||
else | ||
echo '[PASS]' | ||
fi |
Submodule submodule_syntaqx_git_hooks
added at
fa2077