Skip to content

Instantly share code, notes, and snippets.

@naoty
Created August 26, 2015 10:46
Show Gist options
  • Save naoty/ecc6a7706514d5526680 to your computer and use it in GitHub Desktop.
Save naoty/ecc6a7706514d5526680 to your computer and use it in GitHub Desktop.
コミット前にrubocop適用して自動修正するフック
#!/usr/bin/env ruby
files = `git diff --cached --name-only | grep .rb`.split
exit 0 if files.empty?
ok = true
files.each do |file|
next unless File.exist?(file)
result = system "rubocop", "--auto-correct", file
ok = false if result == false
end
exit(ok ? 0 : 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment