git.delta.rocks / unique-network / refs/commits / e6ed5f4e38db

difftreelog

source

.githooks/pre-commit1.0 KiBsourcehistory
1#!/usr/bin/env bash2#3# Pre-push hook verifying that inappropriate code will not be pushed.45# Colors for the terminal output6RED='\033[0;31m'7GREEN='\033[0;32m'8NC='\033[0m' # No Color910echo "Starting cargo fmt.."11cargo fmt --check12FMT_EXIT="$?"1314# Check that prettier formatting rules are not violated.15if [[ "${FMT_EXIT}" = 0 ]]; then16    echo -e "${GREEN}cargo fmt succeded${NC}"17else18    echo -e "${RED}Commit error!${NC}"19    echo "Please format the code via 'cargo fmt', cannot commit unformatted code"20    exit 121fi2223STAGED_TEST_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep "\.ts$\|\.js$")2425if [[ "$STAGED_TEST_FILES" = "" ]]; then26  echo -e "${GREEN}eslint succeded${NC}"27  exit 028fi2930echo "Starting eslint.."31./js-packages/node_modules/.bin/eslint --max-warnings 0 ${STAGED_TEST_FILES[@]}32ESLINT_EXIT="$?"3334if [[ "${ESLINT_EXIT}" = 0 ]]; then35    echo -e "${GREEN}eslint succeded${NC}"36else37    echo -e "${RED}Commit error!${NC}"38    echo "Please format the code via 'yarn fix', cannot Commit unformatted code"39    exit 140fi4142exit $?