From 24a332e71e1f99419c75fe3ffd7d7e575373fd20 Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Mon, 8 Sep 2025 19:42:51 +0200 Subject: [PATCH] feat(githooks): commit user verification --- .githooks/pre-commit | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 4045a6d..99b758c 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -23,8 +23,7 @@ echo -e "\e[32m➤ [PRETTIER]\e[0m Formatting ok\e[37m - \e[33m$(date +"%H:%M:%S ## ESlint echo -e "\e[35m➤ [ESLINT]\e[0m Checking front code\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" -npx lint-staged --silent - echo $? +npx lint-staged -c ./.eslintrc.json -q if [[ $? != 0 ]]; then echo -e "\e[31m➤ [ESLINT]\e[0m Errors in code\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" exit -1; @@ -32,3 +31,23 @@ fi echo -e "\e[32m➤ [ESLINT]\e[0m Code ok\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" cd .. + +## Commit user verification +banned_users=("Daniel Heras Something") +banned_emails=("dani_heras@hotmail.com") +username=$(git config user.name) +email=$(git config user.email) + +if [[ "${banned_users[@]}" =~ "$username" ]]; then + echo -e "\e[31m➤ [GIT]\e[0m Error while verifying the user, you probably suck\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" + exit -1; +else + echo -e "\e[32m➤ [GIT]\e[0m User ok\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" +fi + +if [[ "${banned_emails[@]}" =~ "$email" ]]; then + echo -e "\e[31m➤ [GIT]\e[0m Error while verifying the user email, you probably suck\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" + exit -1; +else + echo -e "\e[32m➤ [GIT]\e[0m Email ok\e[37m - \e[33m$(date +"%H:%M:%S")\e[0m" +fi