Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

git pre-commit hook for Jammit

View pre_commit_hook-jammit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/env ruby
 
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"

Thanks a lot for this!

In my case I had to require 'rubygems' before requiring jammit.

Also for those who (like me) didn't know where to put this code.. It's a git pre commit hoook and goes in $YOUR_PROJECT_ROOT/.git/hooks/pre-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.