Provides a pre-commit git hook to lint Go files
This commit is contained in:
parent
2c7aad91c6
commit
77a779aebe
|
@ -16,3 +16,9 @@
|
|||
```shell
|
||||
make watch
|
||||
```
|
||||
|
||||
3. (Optionnel mais recommandé) Installer le hook Git `pre-commit`
|
||||
```shell
|
||||
rm -f .git/hooks/pre-commit.sample
|
||||
ln -s "$PWD/misc/git-hooks/pre-commit" .git/hooks/pre-commit
|
||||
```
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
CHANGESET=$(git diff --cached --name-only --diff-filter=ACM)
|
||||
|
||||
function lint_go_files {
|
||||
echo "Linting modified Go files..."
|
||||
( cd "$DIR/../.." && make LINT_ARGS="--new-from-rev=HEAD~ ./..." lint )
|
||||
}
|
||||
|
||||
function main {
|
||||
lint_go_files
|
||||
}
|
||||
|
||||
main
|
Reference in New Issue