Created
March 19, 2013 22:13
-
-
Save dpetersen/5200624 to your computer and use it in GitHub Desktop.
Pre-commit caning.
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 | |
begin | |
require 'rubygems' | |
require 'cane/cli' | |
rescue LoadError | |
warn "You're missing a dependency, either rubygems or cane!" | |
end | |
`git stash -u --keep-index` | |
changed_filenames = `git status --porcelain`.split("\n").map { |s| s.split[-1] } | |
results = changed_filenames.map do |filename| | |
Cane::CLI.run(%W[--no-doc --no-abc --style-measure 100 -f #{filename}]) | |
end | |
all_clear = results.all? { |r| r == true } | |
`git reset --hard` | |
`git stash pop --quiet --index` | |
exit(1) unless all_clear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment