Skip to content

Instantly share code, notes, and snippets.

@cmaggard
Created March 10, 2010 20:08
Show Gist options
  • Save cmaggard/328293 to your computer and use it in GitHub Desktop.
Save cmaggard/328293 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'set'
cmd = "git diff --cached --name-only"
matches = { /\.sass/ => /\.css/, /\.haml/ => /\.html/ }
files = IO.popen(cmd).readlines.map(&:chomp)
fail = false
matches.each_key do |key|
$; = '.'
changed_src = files.grep(key).map(&:split).map(&:shift).to_set
changed_dest = files.grep(matches[key]).map(&:split).map(&:shift).to_set
diff = changed_src - changed_dest
if diff.size > 0 then
puts "DEGENERACY!"
diff.each { |d| puts d }
fail = true
end
end
exit (fail ? 1 : 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment