Extend pre-commit hook to run foodcritic
authorTom Hughes <tom@compton.nu>
Fri, 6 Feb 2015 20:02:47 +0000 (20:02 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 9 Feb 2015 21:04:00 +0000 (21:04 +0000)
hooks/pre-commit

index 6f7912f..de3142e 100755 (executable)
@@ -15,6 +15,10 @@ if IO.popen(["git", "ls-files", "--unmerged"]).read.empty?
 
   ok &&= system("rubocop", *ruby_files) unless ruby_files.empty?
 
+  cookbooks = files.grep(%r{(cookbooks/[^/]+)/}) { Regexp.last_match(1) }.uniq
+
+  ok &&= system("foodcritic", "-f", "any", *cookbooks) unless cookbooks.empty?
+
   system("git", "stash", "pop", "--quiet") if need_stash
 else
   puts "Unmerged files. Resolve before committing."