Skip to content

Instantly share code, notes, and snippets.

@hdznrrd
Created June 20, 2016 11:37
Show Gist options
  • Save hdznrrd/a457246d5bac99a1788cc81ea411fc04 to your computer and use it in GitHub Desktop.
Save hdznrrd/a457246d5bac99a1788cc81ea411fc04 to your computer and use it in GitHub Desktop.
git pre-push hook running build & tests using maven and only pushing if tests succeeded
#!/bin/sh
# git pre-push hook running build & tests using maven and only pushing if tests succeeded
#
# will do a local check-out of your currentl commit state and see if that one builds.
# this will spare you nasty surprises from missing to add files or having broken partially commited files
#
PWD=$(pwd)
ROOT="file://$(git rev-parse --show-toplevel)"
TMP=$(mktemp -d)
cd "$TMP"
git clone "$ROOT" test --depth 1
cd test
mvn clean test
SUCCESS=$?
cd "$PWD"
rm -rf "$TMP"
exit $SUCCESS
@david-m-globant
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment