From 196ea4bb853d322ea6082390ff9730ef5bf3eb84 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 12 Jun 2024 03:21:15 -0500 Subject: [PATCH] feat: allow exclusions in check fmt --- scripts/check-fmt-git-pre-commit.bash | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/check-fmt-git-pre-commit.bash b/scripts/check-fmt-git-pre-commit.bash index 394fb7d3..899f4c65 100755 --- a/scripts/check-fmt-git-pre-commit.bash +++ b/scripts/check-fmt-git-pre-commit.bash @@ -8,11 +8,32 @@ main() { root="$(git rev-parse --show-toplevel)" local files=() + local excluded_files=() + local excluded_dirs=( + "${root}/users/price/dots/.config/vesktop" + ) while IFS= read -r file; do + local add_file=true local fpath="${root}/${file}" - if [[ -r "${fpath}" ]]; then - files+=("${fpath}") + if [[ -r "$fpath" ]]; then + for excluded_dir in "${excluded_dirs[@]}"; do + if [[ "$fpath" == "$excluded_dir"* ]]; then + add_file=false + break + fi + done + + for excluded_file in "${excluded_files[@]}"; do + if [[ "$fpath" == "$excluded_file" ]]; then + add_file=false + break + fi + done + + if [[ "$add_file" == true ]]; then + files+=("$fpath") + fi fi done < <(git diff --name-only --staged --diff-filter=d)