Created
May 9, 2012 13:15
-
-
Save ncuesta/2644403 to your computer and use it in GitHub Desktop.
insist-commit
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
#!/bin/bash | |
### ### | |
## ## | |
# # | |
# Insist on committing some changes using fast:commit # | |
# This script takes at least one argument: # | |
# + The changelist number. # | |
# Optionally, you may indicate the maximum number of attempts # | |
# desired. # | |
# # | |
## ## | |
### ### | |
# Check required arg | |
if [ $# -eq 0 ]; then | |
echo "Missing changelist number. Aborting." | |
exit 1 | |
fi | |
# Check for rake binary | |
RAKE="`which rake`" | |
if [ "x" = "x$RAKE" ]; then | |
echo "Command rake is not available. Aborting." | |
exit 2 | |
fi | |
# Check for Rakefile | |
if [ ! -f Rakefile ]; then | |
echo "There's no Rakefile on the current directory. Aborting." | |
exit 3 | |
fi | |
# Check for limit | |
LIMIT=0 | |
if [ $# -eq 2 ]; then | |
LIMIT=$2 | |
fi | |
RAKE_CMD="$RAKE fast:commit[$1]" | |
# Start obsessive attempts | |
echo "Insisting on committing $1..." | |
TRIES=0 | |
while [ $? -ne 1 ]; do | |
let TRIES++ | |
$RAKE_CMD | |
if [ $LIMIT -eq $TRIES ]; then | |
break | |
fi | |
done | |
# Decrease $TRIES on one unit: the last count was an extra attempt | |
let TRIES-- | |
echo | |
echo "Finally! It took $TRIES attempts to check $1 in." | |
echo "Now head to that CI server and make it go green!" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment