From 6ff53974e34d64f9874c4bc4cbd7d4c7ca9e0b08 Mon Sep 17 00:00:00 2001 From: RDF Date: Thu, 15 Sep 2022 12:00:35 -0300 Subject: [PATCH] init playbook on localhost --- Hooks/pre-commit.j2.bash | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Hooks/pre-commit.j2.bash b/Hooks/pre-commit.j2.bash index 0455307..25eacd3 100644 --- a/Hooks/pre-commit.j2.bash +++ b/Hooks/pre-commit.j2.bash @@ -1,34 +1,21 @@ #!/usr/bin/env bash - shopt -s nullglob declare -a FILES declare -a HIT - echo "Git hook executing: pre-commit..." - -# dump staged filenames into FILES array -FILES=(`git diff --cached --name-only --diff-filter=ACM`) - +FILES=($(git diff --cached --name-only --diff-filter=ACM)) n=0 for i in "${FILES[@]}"; do - WARN=`file --mime "${i}" | grep -i binary` - NAME=`file "${i}" | cut -d":" -f1` - + WARN=$(file --mime "${i}" | grep -i binary) + NAME=$(file "${i}" | cut -d":" -f1) if [ -n "${WARN}" ]; then HIT[$n]="${NAME}" WARN="" echo "${NAME} appears to be a binary blob." exit 1 - elif [[ "${NAME}" == *"blah" ]]; then - true - # do some stuff here - else - true - # do some other stuff here fi let "n++" done - if [ ${#HIT[@]} -gt 0 ]; then - echo " WARNING: Binary data found" + echo "WARNING: Binary data found" fi \ No newline at end of file