Deploy a specific revision with Capistrano

Posted on August 6, 2010, under Coding.

Just about every website that I release, be it at work or at home, is stored in a Git repository, and deployed using Capistrano.

I’ve been debugging this PHP application at work that was written by a 3rd-party. After cleaning up the XSS and SQL injection vulnerabilities in it, we found a new bug. It’s minor, yet important.

While tracking down the offending line, I needed to deploy various revisions of the website. It turns out that it’s really easy to do this with Capistrano:

$ cap -S revision=3f30b6de3c55a8347e5f3de3b43193591e6c7322 beta deploy

One thing I noticed was the need to provide the full SHA-1 object name (AKA revision ID, commit ID). Normally with Git, you can provide the first few characters of a commit ID. For example:

$ git checkout 3f30b6de

instead of

$ git checkout 3f30b6de3c55a8347e5f3de3b43193591e6c7322

I guess Capistrano’s a bit more picky!