Skip to content

Instantly share code, notes, and snippets.

@dysinger
Created November 24, 2009 02:21
Show Gist options
  • Select an option

  • Save dysinger/241576 to your computer and use it in GitHub Desktop.

Select an option

Save dysinger/241576 to your computer and use it in GitHub Desktop.
namespace(:cookbooks) do
desc "make per-cookbook branches from the opscode cookbook repository"
task(:branch) do
Dir.glob("*").select {|x| FileTest.directory?(x) }.each do |path|
`git checkout master`
`git branch -D #{path}`
`git checkout -b #{path}`
`git filter-branch --tree-filter \
'rm -rf .gitignore #{Dir.glob("*").reject {|x| x == path}.join(" ")}' \
--prune-empty HEAD`
`rm -rf .git/refs/original`
`git reset --hard HEAD`
`git push -f origin #{path}`
end
`git checkout master`
`git gc --aggressive`
`git prune`
end
desc "add an opscode cookbook as a branch in this chef repo"
task(:add, :cookbook) do |_,a|
`git checkout -b #{a.cookbook}`
`git merge -s ours --no-commit cookbooks/#{a.cookbook}`
`git read-tree --prefix=cookbooks/ -u cookbooks/#{a.cookbook}`
`git commit -m "Merge cookbooks/#{a.cookbook}"`
end
desc "pull an opscode cookbook's updates into our branch"
task(:update, :cookbook) do |_,a|
`git checkout #{a.cookbook} && \
git pull -s subtree cookbooks #{a.cookbook}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment