Last active
August 29, 2015 14:09
-
-
Save alvarobp/be0adbec727dca097f84 to your computer and use it in GitHub Desktop.
Kata Trainer
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
# mkdir kata-name; cd kata-name | |
# git init . | |
# curl -sL https://gist.github.com/alvarobp/be0adbec727dca097f84/raw -o trainer.sh | |
# git add trainer.sh | |
# echo 'trainer.sh' > .gitignore | |
# git add .gitignore | |
# git commit -m'Kata with trainer.sh' | |
# sh trainer.sh | |
PERIOD=${PERIOD:-120} | |
COMMAND=${COMMAND:-bundle exec rspec} | |
exec >/dev/null | |
exec 2>&1 | |
there_are_changes() { | |
! git diff --quiet && git ls-files --other --exclude-standard --directory | egrep -v '/$' | |
} | |
success() { | |
there_are_changes && git add --all . && git commit -m"$(date)" | |
} | |
failure() { | |
there_are_changes && git reset --hard | |
} | |
run() { | |
echo 'TRAINING STARTED' | |
sleep $PERIOD | |
while true; do | |
eval $COMMAND && success || failure | |
sleep $PERIOD | |
done | |
} | |
run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment