Last active
September 13, 2016 14:29
-
-
Save jwir3/39d484d2b6ac9fdd211e4346ff83998c to your computer and use it in GitHub Desktop.
Check Commits for Compilation
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/bash | |
# Replace this with the command you want to run. It must exit with an | |
# appropriate return code (i.e. nonzero on error) for it to work with this | |
# script. | |
COMMAND="./gradlew installAlphaDebug -q" | |
GIT_DIR="./.git" | |
check() { | |
GIT_COMMIT=`cat "$GIT_DIR"/HEAD` | |
$COMMAND > /dev/null 2>&1 | |
if [ $? -ne 0 ] ; then | |
echo -e "\033[31m\xE2\x9C\x97 $GIT_COMMIT did not compile\033[0m" | |
return 1 | |
else | |
echo -e "\033[32m\xE2\x9C\x93 $GIT_COMMIT compiled successfully\033[0m" | |
return 0 | |
fi | |
} | |
more_to_do() { | |
INTERACTIVE_REBASE="$GIT_DIR/rebase-merge" | |
OTHER_REBASE="$GIT_DIR/rebase-apply" | |
if test -d $INTERACTIVE_REBASE -o -d $OTHER_REBASE ; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
while more_to_do ; do | |
if ! check ; then | |
exit 1 | |
else | |
if more_to_do ; then | |
git rebase --continue > /dev/null 2>&1 | |
else | |
exit 0 | |
fi | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment