Last active
January 23, 2019 13:40
-
-
Save rflpazini/ccebe0708d853371b8cc9153b0a7f92e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
BASE_NAME=$(basename `git rev-parse --show-toplevel`) | |
REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" | |
GREEN="\033[1;32m" | |
NOCOLOR="\033[0m" | |
echo "\nRunning pre-commit checks on $BASE_NAME..." | |
FILES=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.java$") || true) | |
[ -z "$FILES" ] && exit 0 | |
echo "* ๐ Our monkeys started to doing the hard work" | |
COMMA_FILES=$(echo "$FILES" | paste -s -d "," -) | |
"${REPO_ROOT_DIR}/gradlew" goJF -DgoogleJavaFormat.include="$COMMA_FILES" &>/dev/null | |
git add $(echo "$FILES" | paste -s -d " " -) | |
read -a arr <<< $FILES | |
for i in "${arr[@]}" | |
do | |
echo "${GREEN} \xE2\x9C\x94${NOCOLOR} $i" | |
done | |
echo "* ๐ Everything is fine now \n " | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment