From c804da8a1c522256e865c2eabfe533b1e515f3ea Mon Sep 17 00:00:00 2001 From: Xiaozhen Liu Date: Fri, 23 Oct 2020 16:53:35 -0700 Subject: [PATCH] [ggj][engx]chore: update pre-commit (#399) * update pre-commit * move around * clean up --- .githooks/pre-commit | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 1a1c841589..b2ba7fa58f 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -4,36 +4,30 @@ # Set up: # ln -s .githooks/pre-commit .git/hooks/pre-commit +# Constants. +BOLD="\e[1m" +UNSET="\e[0m" +WHITE="\e[97m" +RED="\e[91m" +BACK_MAGENTA="\e[45m" +BACK_BLUE="\e[44m" +BACK_RED="\e[41m" +BACK_GREEN="\e[42m" + # Methods. function echo_error { ERR_MSG=$1 HELP_MSG=$2 - BOLD="\e[1m" - UNSET="\e[0m" - WHITE="\e[97m" - RED="\e[91m" - BACK_MAGENTA="\e[45m" - BACK_BLUE="\e[44m" - BACK_RED="\e[41m" echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_RED Changes NOT committed. $UNSET" echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_RED $WHITE $ERR_MSG $BACK_BLUE $HELP_MSG $UNSET" } function echo_status { STATUS_MSG=$1 - BOLD="\e[1m" - UNSET="\e[0m" - WHITE="\e[97m" - BACK_BLUE="\e[44m" echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $STATUS_MSG $UNSET" } function echo_success { - BOLD="\e[1m" - UNSET="\e[0m" - WHITE="\e[97m" - BACK_GREEN="\e[42m" - BACK_BLUE="\e[44m" echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_GREEN $WHITE SUCCESS. $UNSET All checks passed!" } @@ -66,7 +60,6 @@ then mkdir $BAZEL_CACHE_DIR fi -# Constants. # Check only the staged files. NUM_TOTAL_FILES_CHANGED=$(git diff --cached --name-only | wc -l) NUM_JAVA_FILES_CHANGED=$(git diff --cached --name-only "*.java" | wc -l)