Last active
August 29, 2015 13:57
-
-
Save rhodee/9520692 to your computer and use it in GitHub Desktop.
Ideas for a pre-commit hook. Welcome.
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
#!/usr/bin/env ruby | |
# Drop in .git/hooks | |
# Make executable and get back to werk. | |
# Stash files not to be committed | |
system('git stash -q --keep-index') | |
# check for rake | |
rake_available = system('bundle list | grep rake > /dev/null') | |
minitest_available = system('bundle list | grep minitest > /dev/null') | |
rspec_available = system('bundle list | grep rspec > /dev/null') | |
if rake_available && minitest_available | |
# Run test | |
puts 'Running Tests...' | |
system('bundle exec rake test') | |
end | |
if rspec_available | |
# Run test | |
puts 'Running Tests...' | |
system('bundle exec rspec spec') | |
end | |
# Unstash changes to the working tree that we had stashed | |
system('git stash pop -q') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment