3 # DO NOT EDIT - This file is being maintained by Chef
8 while read oldrev newrev refname
10 if [[ "$refname" = "refs/heads/master" ]]
12 cd /var/lib/chef/<%= @repository %>
14 rm -f cookbooks/*/metadata.json(N)
16 git pull --rebase --quiet
18 oldrev=$(git merge-base $oldrev $newrev)
20 for change in "${(f)$(git diff --name-status $oldrev..$newrev)}"
25 if [[ $file == roles/*.rb ]]
28 A|M) knife role from file "${file}";;
29 D) knife role delete -y "${file:t:r}";;
31 elif [[ $file == data_bags/*/*.json ]]
35 knife data bag create "${file:h:t}"
36 knife data bag from file "${file:h:t}" "${file:t}";;
38 knife data bag delete -y "${file:h:t}" "${file:t:r}";;
40 elif [[ $file == cookbooks/* ]]
42 cookbook="${${file#[^/]*/}%%/*}"
44 if [[ -d "cookbooks/${cookbook}" ]]
46 updated_cookbooks+=("$cookbook")
48 deleted_cookbooks+=("$cookbook")
53 if [[ -n "$updated_cookbooks" ]]
55 knife cookbook upload "${(ou)updated_cookbooks[@]}"
58 if [[ -n "$deleted_cookbooks" ]]
60 for cookbook in "${(ou)deleted_cookbooks[@]}"
62 knife cookbook delete -y "$cookbook"