From fa18237a578c38e024db86f14d152c53d157bcce Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Fri, 28 Jul 2023 20:03:28 -0400 Subject: [PATCH] added git pre-commit hook --- .githooks/pre-commit | 16 ++++++++++++++++ modules/git.nix | 1 + 2 files changed, 17 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..65afbb1 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +STAGED="$(git diff --name-only --cached | grep "**.nix" | tr '\n' ' ')" + +if [ -z "$STAGED" ]; then + exit 0 +fi + +for i in $STAGED; do + statix fix -- "$i" +done + +deadnix -qe $STAGED +alejandra -q $STAGED + +git add $STAGED diff --git a/modules/git.nix b/modules/git.nix index 2b7c7e9..5a1f14b 100644 --- a/modules/git.nix +++ b/modules/git.nix @@ -25,6 +25,7 @@ _: { autoSetupRemote = true; }; advice.addIgnoredFile = false; + core.hooksPath = ".githooks"; }; }; };