task :default => :git_push task :git_push do wdir = Dir.pwd dir = "/tmp/share_repo.git" rm_rf dir mkdir_p dir cp "breakout.ini", dir cd dir run "git --bare init" rm 'hooks/post-receive' cd '..' ln_sf "#{wdir}/git-post-receive.rb", File.join(dir, 'hooks/post-receive') src_dir = "/tmp/gizmo_work.git" rm_rf src_dir mkdir_p src_dir cd src_dir run "git init" make_changes("test me", 5) run "git add ." git_commit_all "first commit\nblah blah" # second commit in first push make_changes("second test", 5) run "git add ." git_commit_all "second commit" run "git push #{dir} master" make_changes("new line with test", 5) git_commit_all "new changes 2" make_changes("_with_ -test- ", 5) git_commit_all "new changes 3" run "git push #{dir} master" run "git rm file0.txt" git_commit_all "removed file0.txt" run "git push #{dir} master" run "git checkout -b newb" run "git rm file2.txt" git_commit_all "newb first commit" run "git push #{dir} newb" run "git rm file3.txt" git_commit_all "newb second commit" run "git push #{dir}" run "git checkout master" end def run(cmd) puts "$ #{cmd}" system(cmd) end def make_changes(text, n_files) n_files.times do |i| File.open("file#{i}.txt", "a") do |f| f.write("#{i}." + text + "\n") end end end def git_commit_all(msg) run "git-commit -a -m '#{msg}'" end