Last active
September 23, 2020 13:57
-
-
Save tsavola/60c7f10f55898e96d82286b0b64aba88 to your computer and use it in GitHub Desktop.
Git pre-commit hook script which runs golintapi
This file contains hidden or 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 | |
# | |
# Installation instructions: | |
# - go get golang.org/x/lint/golint | |
# - go get github.com/tsavola/golintapi | |
# - Copy this script to your local Git repository as .git/hooks/pre-commit | |
# - chmod +x .git/hooks/pre-commit | |
# | |
# Note: this script doesn't abort the commit, just displays warnings. | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Empty object. | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
# Redirect to stderr. | |
exec 1>&2 | |
git diff-index --cached --name-only --diff-filter=ACMR $against -- | grep -E '\.go$' | xargs golintapi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment