Created
December 1, 2017 07:15
-
-
Save hontas/c2cb5bbab474a4e04ec9bcc146cef7d8 to your computer and use it in GitHub Desktop.
pre-push hook linting changed files and running test + checkstyle
This file contains 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
#!/usr/bin/env bash | |
printf "<pre-push>\n"; | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$BRANCH" = "master" ]]; then | |
cd frontend; | |
FRONTEND_DIFF=`git diff-index --name-only --relative origin/master`; | |
if [ "$FRONTEND_DIFF" ]; | |
then | |
printf "Frontend files changed: \n$FRONTEND_DIFF\n"; | |
printf "************* ESLINT *************\n" | |
node_modules/.bin/eslint $FRONTEND_DIFF; | |
printf "************* MOCHA TESTS *************\n" | |
node_modules/.bin/mocha "src/{comhem/test/**/*.*,**/*.spec.*}" --reporter progress | |
else | |
printf 'No frontend changes\n'; | |
fi; | |
cd .. | |
JAVA_DIFF=`git diff-index --name-only --relative origin/master | grep .java | sed 's/.*\/java/**/g' | tr '\n' ',' | sed 's/,$//'` | |
if [ "$JAVA_DIFF" ]; | |
then | |
printf "Java files changed\n$JAVA_DIFF\n" | |
printf "************* CHECKSTYLE *************\n" | |
mvn checkstyle:check -f src/pom.xml -Dcheckstyle.includes="$JAVA_DIFF" -q | |
else | |
printf "No java changes\n"; | |
fi; | |
fi; | |
printf "</pre-push>\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment