mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 06:22:57 +00:00
pre-commit hook and in ci pipeline. Found issues can be fixed automatically via make fmt.
35 lines
740 B
Smarty
Executable File
35 lines
740 B
Smarty
Executable File
#!/bin/bash
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;33m'
|
|
CYAN='\033[0;36m'
|
|
NC='\033[0m' # No Color
|
|
|
|
function check {
|
|
name=$1
|
|
prefix=$2
|
|
files=$(git diff --cached --name-only --diff-filter=ACM | grep $prefix)
|
|
shift; shift;
|
|
echo -n "checking $name ";
|
|
if [ -z "$files" ]; then
|
|
echo -e "${CYAN}[NOT APPLICABLE]${NC}"
|
|
exit 0;
|
|
fi
|
|
|
|
cd $(git rev-parse --show-toplevel)
|
|
|
|
out=$($@ $files)
|
|
if [ $? -eq 0 ];
|
|
then
|
|
echo -e "${GREEN}[OK]${NC}"
|
|
cd -
|
|
else
|
|
echo -e "${RED}[FAILED]${NC}"
|
|
echo -e "Please inspect the output below and run make fmt to fix automatically\n"
|
|
echo -e "$out"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check rustfmt .rs rustfmt --check --edition=2018
|