archidata/tools/pre-commit

28 lines
595 B
Plaintext
Raw Normal View History

2023-11-13 21:38:07 +01:00
#!/usr/bin/env bash
# get bash colors and styles here:
# http://misc.flogisoft.com/bash/tip_colors_and_formatting
C_RESET='\e[0m'
C_RED='\e[31m'
C_GREEN='\e[32m'
C_YELLOW='\e[33m'
function __run() #(step, name, cmd)
{
local color output exitcode
printf "${C_YELLOW}[%s]${C_RESET} %-20s" "$1" "$2"
output=$(eval "$3" 2>&1)
exitcode=$?
if [[ 0 == $exitcode ]]; then
echo -e "${C_GREEN}OK!${C_RESET}"
else
2024-01-06 21:03:03 +01:00
echo -e "${C_RED}ERROR! (${exitcode})${C_RESET}\n\n$output"
2023-11-13 21:38:07 +01:00
exit 1
fi
}
2024-01-17 20:19:10 +01:00
__run "1/1" "Check JAVA code format" "mvn formatter:validate"
2023-11-13 21:38:07 +01:00