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 its 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 heres 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 were back to a one-liner:
$ sake git:update
Update: I just added
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.