Wed 30 Jan 2008
Update: I’m ditching Sake for Thor. These tasks have been ported to thor and are available on github.
I’ve started using Git as my SCM of choice for Subversion projects over the last several months and have found that, while I don’t want to use Subversion anymore, there are some things it makes easier than git. For example, let’s say you’re working on something and you want to pull in the changes from other people on your team. With svn it’s simply:
$ svn up
With git things are different, since it only merges changesets and not locally changed files. This was a pain before git-stash came along, since I’d have to back out a change, update, and then reapply it. Even with git-stash things are a bit more painful. Here’s the equivalent to the above for a git-svn project:
$ git stash $ git svn rebase $ git stash apply
Oh, and that’s only if you’re on the master branch. If you’re on another one (and you should be), then here’s what it looks like if you want to keep master up to date too:
$ git stash $ git checkout master $ git svn rebase $ git checkout mybranch $ git rebase master $ git stash apply
Whew! Note that this mostly applies to git-svn projects. For regular git projects a git-pull will do nicely.
I got sick of this, and I noticed that the Rubinius project uses a Rakefile to handle a fair number of the git commands, including updating and pushing. Here’s a Sake script that gives you two tasks: git:update and git:push which automatically check whether the project is a git-svn project and do the right thing. Install it like so:
$ sake -i http://pastie.caboo.se/147964.txt
And now we’re back to a one-liner:
$ sake git:update
Update: I just added git:open and git:close which you should think of as opening and closing issues. They just create and delete branches and can be used like this:
$ sake git:open * Name your branch: ofx * Switching to master Switched to branch "master" Switched to a new branch "ofx"
$ sake git:close * Switching to master * Deleting branch ofx
And don’t worry, git:close is safe and won’t destroy your work if you haven’t merged it yet:
$ sake git:close * Switching to master * Deleting branch ofx * Branch ofx isn't a strict subset of master, quitting
Update: I gave this its own repo on github, so go forth, and git.
February 5th, 2008 at 13.57
And then you can alias these to shorter git commands:
[alias]up = !sake git:update
ci = !sake git:push
Yay!
March 1st, 2008 at 00.55
These look awesome.
March 1st, 2008 at 13.49
Thanks Brian, here’s my somewhat less advanced solution I’ve been using for a while for svn repo’s. Still need to stash manually, though.
[alias]
spull = !git-svn fetch && git-svn rebase
spush = !git-svn dcommit
March 2nd, 2008 at 14.37
sake git:updatefrom a branch of a git-svn branch worked deliciously.March 5th, 2008 at 05.13
Would you be interested in a task for gitifying a svn repo? I created one based on Dr. Nics ‘gitify’-script (http://drnicwilliams.com/2007/11/22/going-offline-without-your-favourite-subversion-repository/).
April 3rd, 2008 at 08.09
Amazing set of tasks! I am definitely enjoying it.
I had only an small glitch with my workflow. I usually do like this:
git checkout master
git merge mybranch
git svn dcommit (or git push)
git checkout mybranch
git rebase master
I added the merge part and reordered the flow a little git at the git:push task. You can see my changes here:
http://www.akitaonrails.com/2008/4/3/git-com-sake