diff --git a/Makefile b/Makefile index a4a0a0c..1ebba7d 100644 --- a/Makefile +++ b/Makefile @@ -76,3 +76,8 @@ clean: .PHONY: lint lint: ./scripts/lint/lint.sh + +.PHONY: git-config +git-config: + $(eval HOOKS = "$(shell git rev-parse --git-dir)/hooks") + ln -sfrv scripts/hooks/pre-commit.sh "$(HOOKS)/pre-commit" diff --git a/scripts/deps.sh b/scripts/deps.sh index c12e16b..0900796 100755 --- a/scripts/deps.sh +++ b/scripts/deps.sh @@ -66,6 +66,9 @@ fi msg "Initializing submodules" git submodule update --init --recursive +msg "Installing git hooks" +make git-config + RUSTUP_NEW_INSTALL=0 if which rustup &> /dev/null; then msg "Updating rustup" diff --git a/scripts/hooks/pre-commit.sh b/scripts/hooks/pre-commit.sh new file mode 100755 index 0000000..0221520 --- /dev/null +++ b/scripts/hooks/pre-commit.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only + +make lint 2>/dev/null || { + echo -e "\nissues found, not committing" + exit 1 +}