]> git.openstreetmap.org Git - chef.git/commitdiff
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 6f7912f1f726a46b28449e8cf007d58c650f23cd..de3142ea000a0a567f6311797c982d4f6ec309fa 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."