Created
March 26, 2017 23:24
-
-
Save dharFr/c7c42ea4ad94d828536f8ffae6f089d6 to your computer and use it in GitHub Desktop.
Shellcheck pre-commit hook
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
#!/bin/sh | |
# | |
# This pre-commit hook run `shellcheck` against your code when you go to commit. | |
# See: http://www.shellcheck.net/ | |
# | |
# To use this script copy it to .git/hooks/pre-commit and make it executable. | |
# Work out what to diff against, really HEAD will work for any established repository. | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
# get updated files | only .sh files (+ .bashrc/.zshrc) | shellcheck | |
git diff-index --cached --name-only $against | grep -e \.bashrc -e \.zshrc -e \.bash_profile -e \\.sh$ | xargs shellcheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment