Skip to content

Instantly share code, notes, and snippets.

@alvarobp
Last active August 29, 2015 14:09
Show Gist options
  • Save alvarobp/be0adbec727dca097f84 to your computer and use it in GitHub Desktop.
Save alvarobp/be0adbec727dca097f84 to your computer and use it in GitHub Desktop.
Kata Trainer
# 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