Created
August 26, 2015 10:46
-
-
Save naoty/ecc6a7706514d5526680 to your computer and use it in GitHub Desktop.
コミット前にrubocop適用して自動修正するフック
This file contains hidden or 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 | |
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