AdGuardHome/.githooks/pre-commit
Artem Baskal 38366ba801 Setup pre-commit lint hook
Squashed commit of the following:

commit 02591b74c184faf7f7156e95cf05a78fb0ea22a7
Merge: 4057c8ae a32c1f2e
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Wed Jul 15 12:36:20 2020 +0300

    Merge branch 'master' into feature/git-hooks

commit 4057c8ae117dfb5de493769dbf1577c8d59035a4
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Tue Jul 14 20:04:38 2020 +0300

    Review changes

commit 2400ab77d9e0e3f7b62b0ffd64aeccf369ff84cd
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Tue Jul 14 16:27:14 2020 +0300

    Add lint-js and lint-go to .PHONY

commit 8a4efc2cb4f2d53ebea4b88b8182e4c1eb7812eb
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Tue Jul 14 15:47:14 2020 +0300

    Run linter only if corresponding file extension is changed

commit 8e2e110e9c9c3f865503cf3c0cd3e31dd4579b71
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Mon Jul 13 19:07:42 2020 +0300

    Setup pre-commit lint hooks
2020-07-15 12:49:08 +03:00

13 lines
237 B
Bash
Executable File

#!/bin/bash
set -e;
git diff --cached --name-only | grep -q '.js$' && make lint-js;
found=0
git diff --cached --name-only | grep -q '.go$' && found=1
if [ $found == 1 ]; then
make lint-go || exit 1
go test ./... || exit 1
fi
exit 0;