-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeremy MAURO
committed
Mar 14, 2013
0 parents
commit ee7a47c
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# check for whitespace errors | ||
git_ws_check = `git diff-index --check --cached HEAD --` | ||
unless $?.success? | ||
puts git_ws_check | ||
exit 1 | ||
end | ||
|
||
COOKBOOK_PATH = File.split `git rev-parse --show-toplevel` | ||
PARENT_PATH = COOKBOOK_PATH[0] | ||
COOKBOOK_NAME = COOKBOOK_PATH[1].chomp # remove trailing newline | ||
|
||
puts 'Running knife cookbook test...' | ||
knife_output = `knife cookbook test #{ COOKBOOK_NAME } -o #{ PARENT_PATH } -c ~/chef/wit/chef-repo/.chef/knife.rb` | ||
unless $?.success? | ||
puts knife_output | ||
exit 1 | ||
end | ||
|
||
puts 'Running tailor...' | ||
|
||
# Get the file names of (A)dded, (C)opied, (M)odified Ruby files | ||
STAGED_FILES = `git diff-index --name-only --diff-filter=ACM HEAD -- '*.rb'` | ||
STAGED_FILES.lines do |file| | ||
file.chomp! # remove carriage returns | ||
puts file | ||
tailor_output = `tailor --max-line-length 999 #{ file }` | ||
unless $?.success? | ||
puts tailor_output | ||
exit 1 | ||
end | ||
end | ||
|
||
puts "Running foodcritic..." | ||
fc_output = `foodcritic --epic-fail any #{ File.join(PARENT_PATH, COOKBOOK_NAME) }` | ||
unless $?.success? | ||
puts fc_output | ||
exit 1 | ||
end |