From 5b44e97088e426e7552d2f9cc0edbb98b3bcb728 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Fri, 5 May 2023 18:32:40 +0200 Subject: [PATCH] lint: exclude file generated by nvfetcher Fix pre-commit hook to only format staged files --- shell/hooks/pre-commit.sh | 8 ++++---- treefmt.toml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/hooks/pre-commit.sh b/shell/hooks/pre-commit.sh index 23776793..45efec25 100755 --- a/shell/hooks/pre-commit.sh +++ b/shell/hooks/pre-commit.sh @@ -7,15 +7,15 @@ else against=$(${git}/bin/git hash-object -t tree /dev/null) fi -diff="git diff-index --name-only --cached $against --diff-filter d" - -mapfile -t all_files < <($diff) - # Stash only unstaged changes, keeping staged changes old_stash=$(git rev-parse --quiet --verify refs/stash) git stash push --quiet --keep-index -m 'Unstaged changes before pre-commit hook' new_stash=$(git rev-parse --quiet --verify refs/stash) +diff="git diff-index --name-only --cached $against --diff-filter d" + +mapfile -t all_files < <($diff) + # Format staged files if ((${#all_files[@]} != 0)); then treefmt "${all_files[@]}" && diff --git a/treefmt.toml b/treefmt.toml index c7c1710d..41ee3051 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -1,6 +1,7 @@ [formatter.nix] command = "alejandra" includes = ["*.nix"] +excludes = ["pkgs/_sources/generated.nix"] [formatter.prettier] command = "prettier"