Skip to content

Instantly share code, notes, and snippets.

@dpetersen
Created March 19, 2013 22:13
Show Gist options
  • Save dpetersen/5200624 to your computer and use it in GitHub Desktop.
Save dpetersen/5200624 to your computer and use it in GitHub Desktop.
Pre-commit caning.
#!/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