diff --git a/doc/prepa-dev.md b/doc/prepa-dev.md index 578699f..2ae7b91 100644 --- a/doc/prepa-dev.md +++ b/doc/prepa-dev.md @@ -15,4 +15,10 @@ 2. Lancer le serveur ```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 ``` \ No newline at end of file diff --git a/misc/git-hooks/pre-commit b/misc/git-hooks/pre-commit new file mode 100755 index 0000000..97f1d92 --- /dev/null +++ b/misc/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 \ No newline at end of file