-
-
Save ckozus/973695 to your computer and use it in GitHub Desktop.
git pre-commit hook for Jammit
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 | |
require 'rubygems' | |
require 'jammit' | |
print "Jammit check... " | |
status_before = %x[git status --porcelain --untracked-files=no] | |
Jammit.package! | |
status_after = %x[git status --porcelain --untracked-files=no] | |
jammit_files = (status_after.split("\n") - status_before.split("\n")).map { |f| f.split[1] } | |
unless jammit_files.empty? | |
puts "FAIL" | |
puts "Looks like you forgot to run jammit" | |
puts "Run `git add #{jammit_files.join(' ')}` and try committing again" | |
exit 1 | |
end | |
puts "PASS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment