From: Tom Hughes Date: Fri, 6 Feb 2015 20:02:47 +0000 (+0000) Subject: Extend pre-commit hook to run foodcritic X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/ae2ef9ff4f0542d2bb2f8bbe6d6b6f27ec5c55f8 Extend pre-commit hook to run foodcritic --- diff --git a/hooks/pre-commit b/hooks/pre-commit index 6f7912f1f..de3142ea0 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -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."